@equinor/fusion-framework-module-msal-node 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +168 -69
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/version.d.ts +1 -1
- package/docs/libsecret.md +140 -0
- package/package.json +1 -1
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @equinor/fusion-framework-module-msal-node
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3361](https://github.com/equinor/fusion-framework/pull/3361) [`1f629b5`](https://github.com/equinor/fusion-framework/commit/1f629b556c4e26170b1eb6ad8823c082cb2ac59d) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - Add caution message about Linux support.
|
|
8
|
+
|
|
9
|
+
## 1.0.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#3343](https://github.com/equinor/fusion-framework/pull/3343) [`c1cd89a`](https://github.com/equinor/fusion-framework/commit/c1cd89abad4ca8f232a497316232d1f5ac8c530a) Thanks [@odinr](https://github.com/odinr)! - Comprehensive documentation overhaul with enhanced developer experience and platform-specific guidance.
|
|
14
|
+
|
|
15
|
+
- **Complete README rewrite** with modern structure and comprehensive examples
|
|
16
|
+
- **Added detailed API reference** with TypeScript interfaces and method documentation
|
|
17
|
+
- **Enhanced authentication mode documentation** with clear use cases and examples
|
|
18
|
+
- **Added comprehensive configuration guide** with required/optional settings tables
|
|
19
|
+
- **Created platform-specific libsecret setup guide** with Windows, macOS, and Linux instructions
|
|
20
|
+
- **Improved troubleshooting section** with common issues and platform-specific solutions
|
|
21
|
+
- **Added quick start examples** for all authentication modes (token_only, silent, interactive)
|
|
22
|
+
- **Enhanced security documentation** explaining platform keychains and encryption
|
|
23
|
+
|
|
24
|
+
**New Documentation:**
|
|
25
|
+
|
|
26
|
+
- `docs/libsecret.md` - Platform-specific credential storage setup guide
|
|
27
|
+
- Comprehensive Windows build tools installation instructions
|
|
28
|
+
- Enhanced Linux libsecret installation for multiple distributions
|
|
29
|
+
- macOS troubleshooting and setup guidance
|
|
30
|
+
|
|
31
|
+
**Key Improvements:**
|
|
32
|
+
|
|
33
|
+
- Clear separation between authentication modes with practical examples
|
|
34
|
+
- Platform-specific installation and troubleshooting guidance
|
|
35
|
+
- Better developer onboarding with quick start examples
|
|
36
|
+
- Comprehensive API reference with TypeScript interfaces
|
|
37
|
+
- Enhanced security documentation explaining credential storage
|
|
38
|
+
|
|
3
39
|
## 1.0.1
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,125 +1,224 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
`@equinor/fusion-framework-msal-node` enables secure authentication for the Fusion Framework in Node.js environments using Microsoft's MSAL (Microsoft Authentication Library) to integrate with Azure Active Directory (Azure AD).
|
|
1
|
+
`@equinor/fusion-framework-module-msal-node` provides secure Azure AD authentication for Node.js applications using Microsoft's MSAL (Microsoft Authentication Library). Perfect for CLI tools, background services, and automated processes that need to authenticate with Microsoft services.
|
|
4
2
|
|
|
5
3
|
## Features
|
|
6
4
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
|
|
13
|
-
- `silent`: Acquires tokens silently using cached or refresh tokens (background services, scripts).
|
|
14
|
-
- `interactive`: Prompts users for authentication via a local HTTP server (CLI tools, development).
|
|
5
|
+
- **Multiple Authentication Modes**: Choose the right auth flow for your use case
|
|
6
|
+
- **Secure Token Storage**: Encrypted credential storage using platform keychains
|
|
7
|
+
- **Easy Integration**: Simple API that works seamlessly with Fusion Framework
|
|
8
|
+
- **Token Management**: Automatic token refresh and caching
|
|
9
|
+
- **Cross-Platform**: Works on Windows, macOS, and Linux
|
|
10
|
+
- **Zero Configuration**: Sensible defaults with optional customization
|
|
15
11
|
|
|
16
|
-
##
|
|
12
|
+
## Quick Start
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @equinor/fusion-framework-module-msal-node
|
|
16
|
+
```
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
| `silent` | Acquires tokens silently using cached or refresh tokens, without user input. | Background services, pre-seeding commands. |
|
|
24
|
-
| `interactive` | Prompts user login via a browser, using a local HTTP server for callbacks. | CLI tools, development, manual operations. |
|
|
18
|
+
```typescript
|
|
19
|
+
import { enableAuthModule } from '@equinor/fusion-framework-module-msal-node';
|
|
20
|
+
import { ModulesConfigurator } from '@equinor/fusion-framework-module';
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
Ideal for scenarios where a token is already available (e.g., via CI/CD). No interaction with Azure AD is required.
|
|
22
|
+
const configurator = new ModulesConfigurator();
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
enableAuthModule(configurator, (builder) => {
|
|
25
|
+
builder.setMode('interactive');
|
|
26
|
+
builder.setClientId('your-client-id');
|
|
27
|
+
builder.setTenantId('your-tenant-id');
|
|
28
|
+
});
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const framework = await initialize();
|
|
31
|
+
const token = await framework.auth.acquireAccessToken({
|
|
32
|
+
scopes: ['https://graph.microsoft.com/.default']
|
|
33
|
+
});
|
|
34
|
+
```
|
|
34
35
|
|
|
35
|
-
##
|
|
36
|
+
## Authentication Modes
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
Choose the authentication mode that best fits your application's needs:
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
| Mode | Description | Best For | User Interaction |
|
|
41
|
+
|------|-------------|----------|------------------|
|
|
42
|
+
| **`token_only`** | Uses a pre-provided access token | CI/CD pipelines, serverless functions | None |
|
|
43
|
+
| **`silent`** | Uses cached credentials for background auth | Background services, scheduled tasks | None |
|
|
44
|
+
| **`interactive`** | Browser-based login with local server | CLI tools, development, user-facing apps | Required |
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
### When to Use Each Mode
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
- **`token_only`**: When you already have a valid access token (e.g., from environment variables, CI/CD secrets)
|
|
49
|
+
- **`silent`**: When you need background authentication without user interaction (e.g., scheduled jobs, background services)
|
|
50
|
+
- **`interactive`**: When you need user login (e.g., CLI tools, development environments, user-facing applications)
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
## Secure Token Storage
|
|
53
|
+
|
|
54
|
+
The module uses `@azure/msal-node-extensions` for enterprise-grade security:
|
|
55
|
+
|
|
56
|
+
- **🔒 Platform Keychains**: Windows Credential Manager, macOS Keychain, Linux libsecret
|
|
57
|
+
- **🔐 Encryption at Rest**: Tokens encrypted using platform-specific mechanisms
|
|
58
|
+
- **🔄 Automatic Refresh**: Seamless token renewal without user intervention
|
|
59
|
+
- **🌐 Cross-Platform**: Consistent security across Windows, macOS, and Linux
|
|
48
60
|
|
|
49
|
-
|
|
61
|
+
## Usage Examples
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
### Token-Only Mode (CI/CD)
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
Perfect for automated processes where you already have a valid token:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { enableAuthModule } from '@equinor/fusion-framework-module-msal-node';
|
|
55
69
|
import { ModulesConfigurator } from '@equinor/fusion-framework-module';
|
|
56
70
|
|
|
57
|
-
const configurator = new ModulesConfigurator
|
|
71
|
+
const configurator = new ModulesConfigurator();
|
|
58
72
|
|
|
59
73
|
enableAuthModule(configurator, (builder) => {
|
|
60
74
|
builder.setMode('token_only');
|
|
61
|
-
builder.setAccessToken(
|
|
75
|
+
builder.setAccessToken(process.env.ACCESS_TOKEN); // From CI/CD secrets
|
|
62
76
|
});
|
|
63
77
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
const framework = await initialize();
|
|
79
|
+
const token = await framework.auth.acquireAccessToken({
|
|
80
|
+
scopes: ['https://graph.microsoft.com/.default']
|
|
81
|
+
});
|
|
67
82
|
```
|
|
68
83
|
|
|
69
|
-
###
|
|
84
|
+
### Silent Mode (Background Services)
|
|
70
85
|
|
|
71
|
-
|
|
86
|
+
For background services that need to authenticate without user interaction:
|
|
72
87
|
|
|
73
|
-
```
|
|
74
|
-
import { enableAuthModule
|
|
88
|
+
```typescript
|
|
89
|
+
import { enableAuthModule } from '@equinor/fusion-framework-module-msal-node';
|
|
75
90
|
import { ModulesConfigurator } from '@equinor/fusion-framework-module';
|
|
76
91
|
|
|
77
|
-
const configurator = new ModulesConfigurator
|
|
92
|
+
const configurator = new ModulesConfigurator();
|
|
78
93
|
|
|
79
94
|
enableAuthModule(configurator, (builder) => {
|
|
80
95
|
builder.setMode('silent');
|
|
81
|
-
builder.setClientId(
|
|
82
|
-
builder.setTenantId(
|
|
96
|
+
builder.setClientId(process.env.AZURE_CLIENT_ID);
|
|
97
|
+
builder.setTenantId(process.env.AZURE_TENANT_ID);
|
|
83
98
|
});
|
|
84
99
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
100
|
+
const framework = await initialize();
|
|
101
|
+
|
|
102
|
+
// This will use cached credentials or fail if no valid cache exists
|
|
103
|
+
try {
|
|
104
|
+
const token = await framework.auth.acquireAccessToken({
|
|
105
|
+
scopes: ['https://graph.microsoft.com/.default']
|
|
106
|
+
});
|
|
107
|
+
console.log('Authenticated successfully');
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error('Silent authentication failed:', error.message);
|
|
110
|
+
}
|
|
88
111
|
```
|
|
89
112
|
|
|
90
|
-
###
|
|
113
|
+
### Interactive Mode (CLI Tools)
|
|
91
114
|
|
|
92
|
-
|
|
115
|
+
For CLI tools and development environments that require user login:
|
|
93
116
|
|
|
94
|
-
```
|
|
95
|
-
import { enableAuthModule
|
|
117
|
+
```typescript
|
|
118
|
+
import { enableAuthModule } from '@equinor/fusion-framework-module-msal-node';
|
|
96
119
|
import { ModulesConfigurator } from '@equinor/fusion-framework-module';
|
|
97
120
|
|
|
98
|
-
const configurator = new ModulesConfigurator
|
|
121
|
+
const configurator = new ModulesConfigurator();
|
|
99
122
|
|
|
100
123
|
enableAuthModule(configurator, (builder) => {
|
|
101
124
|
builder.setMode('interactive');
|
|
102
|
-
builder.setClientId(
|
|
103
|
-
builder.setTenantId(
|
|
104
|
-
builder.setServerPort(3000); //
|
|
125
|
+
builder.setClientId(process.env.AZURE_CLIENT_ID);
|
|
126
|
+
builder.setTenantId(process.env.AZURE_TENANT_ID);
|
|
127
|
+
builder.setServerPort(3000); // Optional: custom port
|
|
105
128
|
builder.setServerOnOpen((url) => {
|
|
106
|
-
console.log(
|
|
129
|
+
console.log(`🌐 Please open your browser and navigate to: ${url}`);
|
|
107
130
|
});
|
|
108
131
|
});
|
|
109
132
|
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
133
|
+
const framework = await initialize();
|
|
134
|
+
|
|
135
|
+
// This will open a browser for user login
|
|
136
|
+
const result = await framework.auth.login({
|
|
137
|
+
scopes: ['https://graph.microsoft.com/.default']
|
|
138
|
+
});
|
|
139
|
+
console.log('Login successful:', result.account?.username);
|
|
113
140
|
```
|
|
114
141
|
|
|
115
142
|
## Configuration
|
|
116
143
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
144
|
+
### Required Settings
|
|
145
|
+
|
|
146
|
+
| Setting | Description | Required For |
|
|
147
|
+
|---------|-------------|--------------|
|
|
148
|
+
| `clientId` | Azure AD application client ID | `silent`, `interactive` |
|
|
149
|
+
| `tenantId` | Azure AD tenant ID | `silent`, `interactive` |
|
|
150
|
+
| `accessToken` | Pre-obtained access token | `token_only` |
|
|
151
|
+
|
|
152
|
+
### Optional Settings
|
|
153
|
+
|
|
154
|
+
| Setting | Description | Default | Mode |
|
|
155
|
+
|---------|-------------|---------|------|
|
|
156
|
+
| `serverPort` | Local server port for auth callbacks | `3000` | `interactive` |
|
|
157
|
+
| `serverOnOpen` | Callback when browser opens | `undefined` | `interactive` |
|
|
158
|
+
|
|
159
|
+
### Environment Variables
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Required for silent/interactive modes
|
|
163
|
+
AZURE_CLIENT_ID=your-client-id
|
|
164
|
+
AZURE_TENANT_ID=your-tenant-id
|
|
165
|
+
|
|
166
|
+
# Required for token_only mode
|
|
167
|
+
ACCESS_TOKEN=your-access-token
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## API Reference
|
|
171
|
+
|
|
172
|
+
### `enableAuthModule(configurator, configure)`
|
|
173
|
+
|
|
174
|
+
Enables the MSAL Node module in your Fusion Framework application.
|
|
175
|
+
|
|
176
|
+
**Parameters:**
|
|
177
|
+
- `configurator`: `ModulesConfigurator` - The modules configurator instance
|
|
178
|
+
- `configure`: `(builder: IAuthConfigurator) => void` - Configuration function
|
|
179
|
+
|
|
180
|
+
### `IAuthProvider`
|
|
181
|
+
|
|
182
|
+
The authentication provider interface available at `framework.auth`:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
interface IAuthProvider {
|
|
186
|
+
// Acquire an access token for the specified scopes
|
|
187
|
+
acquireAccessToken(options: {
|
|
188
|
+
scopes: string[];
|
|
189
|
+
interactive?: boolean
|
|
190
|
+
}): Promise<string>;
|
|
191
|
+
|
|
192
|
+
// Login (interactive mode only)
|
|
193
|
+
login(options: { scopes: string[] }): Promise<AuthenticationResult>;
|
|
194
|
+
|
|
195
|
+
// Logout (interactive mode only)
|
|
196
|
+
logout(): Promise<void>;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
120
200
|
|
|
121
201
|
## Troubleshooting
|
|
122
202
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
203
|
+
### Common Issues
|
|
204
|
+
|
|
205
|
+
| Issue | Solution |
|
|
206
|
+
|-------|----------|
|
|
207
|
+
| **Invalid client/tenant ID** | Verify your Azure AD app registration settings |
|
|
208
|
+
| **Port already in use** | Change the `serverPort` or kill the process using the port |
|
|
209
|
+
| **Silent auth fails** | Ensure you've logged in interactively first to cache credentials |
|
|
210
|
+
| **Token expired** | The module handles refresh automatically; check your scopes |
|
|
211
|
+
| **Credential storage errors** | See our [credential storage guide](docs/libsecret.md) |
|
|
212
|
+
|
|
213
|
+
### Getting Help
|
|
214
|
+
|
|
215
|
+
- 📖 [Credential Storage Troubleshooting](docs/libsecret.md) - Platform-specific setup help
|
|
216
|
+
- 🐛 [Report Issues](https://github.com/equinor/fusion/issues) - Bug reports and feature requests
|
|
217
|
+
|
|
218
|
+
## Additional Resources
|
|
219
|
+
|
|
220
|
+
- [Microsoft Graph API Documentation](https://docs.microsoft.com/en-us/graph/)
|
|
221
|
+
- [Azure AD App Registration Guide](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app)
|
|
222
|
+
- [MSAL Node Documentation](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-node)
|
|
223
|
+
- [Fusion Framework Documentation](https://github.com/equinor/fusion-framework)
|
|
224
|
+
|
package/dist/esm/version.js
CHANGED