@owlmeans/oidc 0.1.1 → 0.1.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/LICENSE +1 -1
- package/README.md +48 -488
- package/build/consts.d.ts +2 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +3 -0
- package/build/consts.js.map +1 -1
- package/build/guard.d.ts +2 -2
- package/build/guard.d.ts.map +1 -1
- package/build/guard.js.map +1 -1
- package/build/modules.d.ts +1 -1
- package/build/modules.d.ts.map +1 -1
- package/build/modules.js +3 -3
- package/build/modules.js.map +1 -1
- package/build/types.d.ts +5 -1
- package/build/types.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/consts.ts +5 -0
- package/src/guard.ts +2 -2
- package/src/modules.ts +4 -4
- package/src/types.ts +5 -1
- package/tsconfig.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 OwlMeans Common — Fullstack typescript framework
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,525 +1,85 @@
|
|
|
1
1
|
# @owlmeans/oidc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared OIDC protocol abstractions — guard/gate aliases, models, and module declarations used by both server and browser OIDC packages.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- **Guard Services**: OIDC-based authentication guards for API protection
|
|
12
|
-
- **Client Integration**: Support for OIDC relying party implementations
|
|
13
|
-
- **Provider Support**: Foundation for OIDC identity provider services
|
|
14
|
-
- **Flow Management**: Integration with OwlMeans flow system for authentication workflows
|
|
15
|
-
- **Multi-Provider Support**: Configuration and management of multiple OIDC providers
|
|
7
|
+
- `OIDC_GATE` — gate alias to compose with `gate(...)` inside `guard(...)` declarations
|
|
8
|
+
- `OIDC_GUARD`, `WRAPPED_OIDC`, `OIDC_FLOW`, `OIDC_AUTHEN_MODULE`, `OIDC_WRAPPED_TOKEN` — shared aliases
|
|
9
|
+
- `OidcGuard`, `WithSharedConfig`, `OidcProviderConfig` — shared types
|
|
10
|
+
- Module declarations for the OIDC dispatcher (`/authenticate/oidc/init`, `/authenticate/oidc/process`)
|
|
16
11
|
|
|
17
12
|
## Installation
|
|
18
13
|
|
|
19
14
|
```bash
|
|
20
|
-
|
|
15
|
+
bun add @owlmeans/oidc
|
|
21
16
|
```
|
|
22
17
|
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
### OIDC Provider Configuration
|
|
26
|
-
|
|
27
|
-
The package defines standardized configuration structures for OIDC identity providers, supporting both public and private providers with flexible client configurations.
|
|
28
|
-
|
|
29
|
-
### Authentication Modules
|
|
30
|
-
|
|
31
|
-
Pre-built modules handle OIDC authentication flows, including initialization, callback processing, and token management.
|
|
32
|
-
|
|
33
|
-
### Guard Services
|
|
34
|
-
|
|
35
|
-
OIDC guards provide authentication and authorization for API endpoints using OIDC tokens.
|
|
36
|
-
|
|
37
|
-
### Multi-Tenant Support
|
|
18
|
+
## Usage
|
|
38
19
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
## API Reference
|
|
42
|
-
|
|
43
|
-
### Types
|
|
44
|
-
|
|
45
|
-
#### `OidcSharedConfig`
|
|
46
|
-
Main configuration interface for OIDC functionality.
|
|
20
|
+
Compose `OIDC_GATE` into a guard on a module:
|
|
47
21
|
|
|
48
22
|
```typescript
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ttl?: number // Time-to-live for interaction cookies
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
providers?: OidcProviderConfig[] // OIDC provider configurations
|
|
57
|
-
restrictedProviders?: boolean | string[] // Provider access restrictions
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
#### `OidcProviderConfig`
|
|
62
|
-
Configuration for individual OIDC providers.
|
|
23
|
+
import { module, guard, gate } from '@owlmeans/module'
|
|
24
|
+
import { route } from '@owlmeans/route'
|
|
25
|
+
import { DEFAULT_GUARD } from '@owlmeans/auth-common'
|
|
26
|
+
import { OIDC_GATE } from '@owlmeans/oidc'
|
|
63
27
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
apiClientId?: string // Administrative client ID
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
#### `OidcProviderDescriptor`
|
|
72
|
-
Core provider configuration.
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
interface OidcProviderDescriptor {
|
|
76
|
-
entityId?: string // Entity binding
|
|
77
|
-
service?: string // Service identifier
|
|
78
|
-
discoveryUrl?: string // OIDC discovery endpoint
|
|
79
|
-
basePath?: string // Base path for OIDC endpoints
|
|
80
|
-
clientId: string // OAuth2 client ID
|
|
81
|
-
secret?: string // Client secret
|
|
82
|
-
extraScopes?: string // Additional OAuth2 scopes
|
|
83
|
-
idOverride?: string // Provider ID override
|
|
84
|
-
def?: boolean // Default provider flag (client-side)
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
#### `WithSharedConfig`
|
|
89
|
-
Interface for configurations that include OIDC settings.
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
interface WithSharedConfig {
|
|
93
|
-
oidc: OidcSharedConfig
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Constants
|
|
98
|
-
|
|
99
|
-
#### Module Identifiers
|
|
100
|
-
```typescript
|
|
101
|
-
const OIDC_AUTHEN_MODULE = 'iam-oidc-authen' // OIDC authentication module
|
|
102
|
-
const PROVIDER_INTERACTION = 'oidc-server:interaction' // Provider interaction module
|
|
103
|
-
const OIDC_CLIENT_AUTH = 'oidc-client' // Client authentication module
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
#### Flow and Guard Constants
|
|
107
|
-
```typescript
|
|
108
|
-
const OIDC_FLOW = 'oidc' // OIDC authentication flow
|
|
109
|
-
const OIDC_GUARD = 'guard:oidc' // OIDC guard service
|
|
110
|
-
const OIDC_GUARD_CACHE = 'resource:oidc-guard:cache' // Guard cache resource
|
|
111
|
-
const OIDC_GATE = 'oidc-gate' // OIDC gate service
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
#### Dispatcher Constants
|
|
115
|
-
```typescript
|
|
116
|
-
const DISPATCHER_OIDC_INIT = 'dispatcher:oidc:init' // OIDC initialization
|
|
117
|
-
const DISPATCHER_OIDC = 'dispatcher:oidc:authenticate' // OIDC authentication
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
#### Path and Parameter Constants
|
|
121
|
-
```typescript
|
|
122
|
-
const DEFAULT_PATH = 'oidc' // Default OIDC base path
|
|
123
|
-
const DEFAULT_FRONT = 'oidc-client' // Default frontend identifier
|
|
124
|
-
const INTERACTION_PATH = '/interaction/:uid' // Interaction endpoint path
|
|
125
|
-
const OIDC_CODE_QUERY = 'code' // Authorization code query parameter
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Pre-built Modules
|
|
129
|
-
|
|
130
|
-
The package exports pre-configured modules for OIDC authentication:
|
|
131
|
-
|
|
132
|
-
#### OIDC Initialization Module
|
|
133
|
-
Handles OIDC authentication initialization requests.
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
// Route: POST /authenticate/oidc/init
|
|
137
|
-
// Validates: OIDCAuthInitParamsSchema
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
#### OIDC Processing Module
|
|
141
|
-
Handles OIDC authentication callback processing.
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
// Route: POST /authenticate/oidc/process
|
|
145
|
-
// Validates: OIDCClientAuthPayloadSchema
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## Usage Examples
|
|
149
|
-
|
|
150
|
-
### Basic OIDC Configuration
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
import { OidcSharedConfig } from '@owlmeans/oidc'
|
|
154
|
-
|
|
155
|
-
const oidcConfig: OidcSharedConfig = {
|
|
156
|
-
clientCookie: {
|
|
157
|
-
interaction: {
|
|
158
|
-
name: 'oidc_interaction',
|
|
159
|
-
ttl: 3600 // 1 hour
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
providers: [
|
|
163
|
-
{
|
|
164
|
-
clientId: 'my-app-client',
|
|
165
|
-
secret: 'client-secret',
|
|
166
|
-
discoveryUrl: 'https://auth.example.com/.well-known/openid_configuration',
|
|
167
|
-
extraScopes: 'profile email',
|
|
168
|
-
def: true // Default provider
|
|
169
|
-
}
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Multi-Provider Configuration
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
const multiProviderConfig: OidcSharedConfig = {
|
|
178
|
-
providers: [
|
|
179
|
-
{
|
|
180
|
-
clientId: 'google-client-id',
|
|
181
|
-
discoveryUrl: 'https://accounts.google.com/.well-known/openid_configuration',
|
|
182
|
-
service: 'google',
|
|
183
|
-
extraScopes: 'profile email'
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
clientId: 'microsoft-client-id',
|
|
187
|
-
discoveryUrl: 'https://login.microsoftonline.com/common/v2.0/.well-known/openid_configuration',
|
|
188
|
-
service: 'microsoft',
|
|
189
|
-
extraScopes: 'profile email'
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
clientId: 'internal-client-id',
|
|
193
|
-
secret: 'internal-secret',
|
|
194
|
-
discoveryUrl: 'https://internal-auth.company.com/.well-known/openid_configuration',
|
|
195
|
-
service: 'internal',
|
|
196
|
-
internal: true, // Internal use only
|
|
197
|
-
entityId: 'company-employees'
|
|
198
|
-
}
|
|
199
|
-
],
|
|
200
|
-
restrictedProviders: ['internal'] // Restrict access to internal provider
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Entity-Specific Provider Configuration
|
|
205
|
-
|
|
206
|
-
```typescript
|
|
207
|
-
const entitySpecificConfig: OidcSharedConfig = {
|
|
208
|
-
providers: [
|
|
209
|
-
{
|
|
210
|
-
clientId: 'org-a-client',
|
|
211
|
-
secret: 'org-a-secret',
|
|
212
|
-
discoveryUrl: 'https://auth-org-a.example.com/.well-known/openid_configuration',
|
|
213
|
-
entityId: 'organization-a',
|
|
214
|
-
service: 'org-a'
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
clientId: 'org-b-client',
|
|
218
|
-
secret: 'org-b-secret',
|
|
219
|
-
discoveryUrl: 'https://auth-org-b.example.com/.well-known/openid_configuration',
|
|
220
|
-
entityId: 'organization-b',
|
|
221
|
-
service: 'org-b'
|
|
222
|
-
}
|
|
223
|
-
]
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### OIDC Module Integration
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
import { modules } from '@owlmeans/oidc'
|
|
231
|
-
import { createBasicContext } from '@owlmeans/context'
|
|
232
|
-
|
|
233
|
-
// Create context with OIDC modules
|
|
234
|
-
const context = createBasicContext({
|
|
235
|
-
oidc: oidcConfig
|
|
236
|
-
})
|
|
237
|
-
|
|
238
|
-
// Register OIDC modules
|
|
239
|
-
modules.forEach(module => {
|
|
240
|
-
context.registerModule(module)
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
// Initialize context
|
|
244
|
-
await context.init()
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### Custom OIDC Module
|
|
248
|
-
|
|
249
|
-
```typescript
|
|
250
|
-
import { module, body, filter } from '@owlmeans/module'
|
|
251
|
-
import { route, RouteMethod, backend } from '@owlmeans/route'
|
|
252
|
-
|
|
253
|
-
const customOidcModule = module(
|
|
254
|
-
route('custom-oidc-login', '/auth/custom/login', backend(null, RouteMethod.POST)),
|
|
255
|
-
filter(body(CustomOIDCSchema)),
|
|
256
|
-
// Custom handler implementation
|
|
257
|
-
async (request, reply) => {
|
|
258
|
-
const { provider, redirectUri } = request.body
|
|
259
|
-
|
|
260
|
-
// Custom OIDC initialization logic
|
|
261
|
-
const authUrl = await generateOIDCAuthUrl(provider, redirectUri)
|
|
262
|
-
|
|
263
|
-
reply.resolve({ authUrl }, ModuleOutcome.Ok)
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
### OIDC Guard Usage
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
import { OIDC_GUARD } from '@owlmeans/oidc'
|
|
272
|
-
|
|
273
|
-
// Protect API endpoint with OIDC guard
|
|
274
|
-
const protectedModule = module(
|
|
275
|
-
route('protected-api', '/api/protected', backend()),
|
|
276
|
-
// Guard will validate OIDC tokens
|
|
277
|
-
{ guards: [OIDC_GUARD] },
|
|
278
|
-
async (request, reply) => {
|
|
279
|
-
// Access authenticated user from OIDC token
|
|
280
|
-
const user = request.auth?.user
|
|
281
|
-
|
|
282
|
-
const data = await getProtectedData(user.id)
|
|
283
|
-
reply.resolve(data)
|
|
284
|
-
}
|
|
28
|
+
module(
|
|
29
|
+
route(manager.back.account.base, '/account'),
|
|
30
|
+
guard(DEFAULT_GUARD, gate(OIDC_GATE, [`my-service-account-{entity}`]))
|
|
285
31
|
)
|
|
286
32
|
```
|
|
287
33
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
```typescript
|
|
291
|
-
// Configuration with provider restrictions
|
|
292
|
-
const restrictedConfig: OidcSharedConfig = {
|
|
293
|
-
providers: [
|
|
294
|
-
{ clientId: 'public-provider', service: 'public' },
|
|
295
|
-
{ clientId: 'internal-provider', service: 'internal', internal: true },
|
|
296
|
-
{ clientId: 'partner-provider', service: 'partner' }
|
|
297
|
-
],
|
|
298
|
-
// Only allow internal and partner providers
|
|
299
|
-
restrictedProviders: ['internal', 'partner']
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Check if provider is allowed
|
|
303
|
-
const isProviderAllowed = (providerId: string, config: OidcSharedConfig) => {
|
|
304
|
-
const { restrictedProviders } = config
|
|
305
|
-
|
|
306
|
-
if (restrictedProviders === false) {
|
|
307
|
-
return false // No providers allowed
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (restrictedProviders === true) {
|
|
311
|
-
// Only default provider allowed
|
|
312
|
-
const defaultProvider = config.providers?.find(p => p.def)
|
|
313
|
-
return defaultProvider?.service === providerId
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (Array.isArray(restrictedProviders)) {
|
|
317
|
-
return restrictedProviders.includes(providerId)
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return true // All providers allowed
|
|
321
|
-
}
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
### OIDC Flow Integration
|
|
34
|
+
Extend an app config with shared OIDC config:
|
|
325
35
|
|
|
326
36
|
```typescript
|
|
327
|
-
import {
|
|
328
|
-
import { makeFlowModel } from '@owlmeans/flow'
|
|
37
|
+
import type { WithSharedConfig, OidcProviderConfig } from '@owlmeans/oidc'
|
|
329
38
|
|
|
330
|
-
|
|
331
|
-
const oidcFlow = await makeFlowModel(OIDC_FLOW, flowProvider)
|
|
332
|
-
|
|
333
|
-
// Start authentication flow
|
|
334
|
-
oidcFlow.target('auth-service')
|
|
335
|
-
oidcFlow.entity('user-123')
|
|
336
|
-
|
|
337
|
-
// Navigate through flow steps
|
|
338
|
-
const initState = oidcFlow.transit('init', true, 'Starting OIDC auth')
|
|
339
|
-
const authState = oidcFlow.transit('authenticate', true, 'Provider selected')
|
|
340
|
-
const completeState = oidcFlow.transit('complete', true, 'Authentication successful')
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
### Token Validation
|
|
344
|
-
|
|
345
|
-
```typescript
|
|
346
|
-
import { OIDC_WRAPPED_TOKEN, WRAPPED_OIDC } from '@owlmeans/oidc'
|
|
347
|
-
|
|
348
|
-
// Validate OIDC token
|
|
349
|
-
const validateOIDCToken = async (token: string, providerId: string) => {
|
|
350
|
-
// Extract provider configuration
|
|
351
|
-
const provider = oidcConfig.providers?.find(p => p.service === providerId)
|
|
352
|
-
if (!provider) {
|
|
353
|
-
throw new Error('Provider not found')
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// Validate token with provider
|
|
357
|
-
const tokenInfo = await validateWithProvider(token, provider)
|
|
358
|
-
|
|
359
|
-
// Wrap token for internal use
|
|
360
|
-
return {
|
|
361
|
-
type: OIDC_WRAPPED_TOKEN,
|
|
362
|
-
token: tokenInfo.access_token,
|
|
363
|
-
user: tokenInfo.userInfo,
|
|
364
|
-
provider: providerId
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### Custom Provider Discovery
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
// Dynamic provider discovery
|
|
373
|
-
const discoverOIDCProvider = async (discoveryUrl: string) => {
|
|
374
|
-
const response = await fetch(discoveryUrl)
|
|
375
|
-
const discovery = await response.json()
|
|
376
|
-
|
|
377
|
-
return {
|
|
378
|
-
authorizationEndpoint: discovery.authorization_endpoint,
|
|
379
|
-
tokenEndpoint: discovery.token_endpoint,
|
|
380
|
-
userinfoEndpoint: discovery.userinfo_endpoint,
|
|
381
|
-
jwksUri: discovery.jwks_uri,
|
|
382
|
-
issuer: discovery.issuer
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// Use discovered endpoints
|
|
387
|
-
const provider: OidcProviderConfig = {
|
|
388
|
-
clientId: 'dynamic-client',
|
|
389
|
-
discoveryUrl: 'https://example.com/.well-known/openid_configuration',
|
|
390
|
-
service: 'dynamic-provider'
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
const endpoints = await discoverOIDCProvider(provider.discoveryUrl!)
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
## Advanced Features
|
|
397
|
-
|
|
398
|
-
### Administrative API Integration
|
|
399
|
-
|
|
400
|
-
```typescript
|
|
401
|
-
// Provider with administrative capabilities
|
|
402
|
-
const adminProviderConfig: OidcProviderConfig = {
|
|
403
|
-
clientId: 'public-client-id',
|
|
404
|
-
secret: 'public-client-secret',
|
|
405
|
-
discoveryUrl: 'https://auth.example.com/.well-known/openid_configuration',
|
|
406
|
-
apiClientId: 'admin-client-id', // For administrative operations
|
|
407
|
-
service: 'managed-provider'
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Use administrative client for user management
|
|
411
|
-
const manageUsers = async (provider: OidcProviderConfig) => {
|
|
412
|
-
const adminToken = await getAdminToken(provider.apiClientId!)
|
|
413
|
-
|
|
414
|
-
// Perform administrative operations
|
|
415
|
-
const users = await listUsers(adminToken)
|
|
416
|
-
return users
|
|
417
|
-
}
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
### Cookie Configuration
|
|
421
|
-
|
|
422
|
-
```typescript
|
|
423
|
-
// Custom cookie configuration for interactions
|
|
424
|
-
const cookieConfig: OidcSharedConfig = {
|
|
425
|
-
clientCookie: {
|
|
426
|
-
interaction: {
|
|
427
|
-
name: 'app_oidc_session',
|
|
428
|
-
ttl: 7200 // 2 hours
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// Use in OIDC interaction handling
|
|
434
|
-
const handleInteraction = (req: Request, res: Response) => {
|
|
435
|
-
const cookieName = cookieConfig.clientCookie?.interaction?.name || 'oidc_interaction'
|
|
436
|
-
const ttl = cookieConfig.clientCookie?.interaction?.ttl || 3600
|
|
437
|
-
|
|
438
|
-
res.cookie(cookieName, interactionData, {
|
|
439
|
-
maxAge: ttl * 1000,
|
|
440
|
-
httpOnly: true,
|
|
441
|
-
secure: true
|
|
442
|
-
})
|
|
443
|
-
}
|
|
39
|
+
interface AppConfig extends BasicConfig, WithSharedConfig {}
|
|
444
40
|
```
|
|
445
41
|
|
|
446
|
-
|
|
42
|
+
Type a websocket auth payload:
|
|
447
43
|
|
|
448
44
|
```typescript
|
|
449
|
-
import {
|
|
450
|
-
|
|
451
|
-
try {
|
|
452
|
-
const result = await authenticateWithOIDC(provider, token)
|
|
453
|
-
return result
|
|
454
|
-
} catch (error) {
|
|
455
|
-
if (error instanceof OIDCError) {
|
|
456
|
-
console.error('OIDC authentication failed:', error.message)
|
|
457
|
-
|
|
458
|
-
// Handle specific OIDC errors
|
|
459
|
-
switch (error.code) {
|
|
460
|
-
case 'invalid_token':
|
|
461
|
-
// Handle invalid token
|
|
462
|
-
break
|
|
463
|
-
case 'provider_unavailable':
|
|
464
|
-
// Handle provider unavailability
|
|
465
|
-
break
|
|
466
|
-
default:
|
|
467
|
-
// Handle generic OIDC error
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
throw error
|
|
472
|
-
}
|
|
45
|
+
import type { OidcGuard } from '@owlmeans/oidc'
|
|
46
|
+
import { OIDC_GUARD } from '@owlmeans/oidc'
|
|
473
47
|
```
|
|
474
48
|
|
|
475
|
-
##
|
|
49
|
+
## API
|
|
476
50
|
|
|
477
|
-
|
|
51
|
+
### Constants
|
|
478
52
|
|
|
479
|
-
-
|
|
480
|
-
-
|
|
481
|
-
-
|
|
482
|
-
-
|
|
483
|
-
-
|
|
484
|
-
-
|
|
485
|
-
-
|
|
486
|
-
-
|
|
487
|
-
-
|
|
53
|
+
- `OIDC_GATE` — `'oidc-gate'`
|
|
54
|
+
- `OIDC_GUARD` — `'guard:oidc'`
|
|
55
|
+
- `OIDC_FLOW` — `'oidc'`
|
|
56
|
+
- `WRAPPED_OIDC` — `'wrapped-oidc-authz'`
|
|
57
|
+
- `OIDC_AUTHEN_MODULE` — `'iam-oidc-authen'`
|
|
58
|
+
- `OIDC_WRAPPED_TOKEN` — `'oidc-wrapped-token'`
|
|
59
|
+
- `DISPATCHER_OIDC`, `DISPATCHER_OIDC_INIT` — auth dispatcher module aliases
|
|
60
|
+
- `INTERACTION`, `INTERACTION_PATH` — interaction route aliases
|
|
61
|
+
- `OIDC_GUARD_CACHE` — guard cache resource alias
|
|
488
62
|
|
|
489
|
-
|
|
63
|
+
### Types
|
|
490
64
|
|
|
491
|
-
-
|
|
492
|
-
-
|
|
493
|
-
-
|
|
494
|
-
- Use secure cookies for session management
|
|
495
|
-
- Validate provider discovery documents
|
|
496
|
-
- Implement proper token storage and cleanup
|
|
497
|
-
- Use appropriate scopes and minimize requested permissions
|
|
65
|
+
- `OidcGuard` — guard payload shape (used in WS auth helpers)
|
|
66
|
+
- `WithSharedConfig` — config mixin adding the OIDC fields
|
|
67
|
+
- `OidcProviderConfig` — provider configuration shape
|
|
498
68
|
|
|
499
|
-
##
|
|
69
|
+
## Product-Viable Integration Notes
|
|
500
70
|
|
|
501
|
-
|
|
502
|
-
-
|
|
503
|
-
-
|
|
504
|
-
-
|
|
505
|
-
- Regular review and rotation of client credentials
|
|
71
|
+
- Provider configuration belongs in `cfg.oidc.providers`; viable registers an internal admin provider and a Google provider there.
|
|
72
|
+
- `GOOGLE_SERVICE` is the stable provider service key (`'google'`) and must match browser plugin, backend provider lookup, and identity-linking derivation.
|
|
73
|
+
- `GOOGLE_CLIENT_AUTH` identifies the browser Google auth plugin registered by `@owlmeans/web-oidc-rp/auth/plugins`.
|
|
74
|
+
- `OIDC_GATE` is for OIDC-backed authorization. Apps that only use Google/OIDC for login and authorize against local identity records should define their own product gate alias.
|
|
506
75
|
|
|
507
|
-
###
|
|
508
|
-
- Use meaningful service identifiers for providers
|
|
509
|
-
- Implement proper provider selection UI/UX
|
|
510
|
-
- Handle provider-specific error scenarios
|
|
511
|
-
- Implement fallback authentication methods
|
|
76
|
+
### `modules`
|
|
512
77
|
|
|
513
|
-
|
|
514
|
-
- Validate all OIDC tokens before trusting claims
|
|
515
|
-
- Implement proper session timeout and cleanup
|
|
516
|
-
- Use appropriate redirect URI validation
|
|
517
|
-
- Monitor for suspicious authentication patterns
|
|
78
|
+
Array of dispatcher module declarations: `POST /authenticate/oidc/init` and `POST /authenticate/oidc/process`.
|
|
518
79
|
|
|
519
|
-
|
|
520
|
-
- Cache provider discovery documents appropriately
|
|
521
|
-
- Implement efficient token validation
|
|
522
|
-
- Use connection pooling for provider communication
|
|
523
|
-
- Monitor and optimize authentication flow performance
|
|
80
|
+
## Related Packages
|
|
524
81
|
|
|
525
|
-
|
|
82
|
+
- [`@owlmeans/server-oidc-rp`](../server-oidc-rp) — server-side relying party that consumes these constants
|
|
83
|
+
- [`@owlmeans/web-oidc-rp`](../web-oidc-rp) — browser-side relying party
|
|
84
|
+
- [`@owlmeans/server-oidc-provider`](../server-oidc-provider) — embedded OIDC identity provider
|
|
85
|
+
- [`@owlmeans/auth-common`](../auth-common) — `DEFAULT_GUARD` typically composed alongside `OIDC_GATE`
|
package/build/consts.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export declare const OIDC_FLOW = "oidc";
|
|
|
6
6
|
export declare const OIDC_AUTHEN_MODULE = "iam-oidc-authen";
|
|
7
7
|
export declare const PROVIDER_INTERACTION = "oidc-server:interaction";
|
|
8
8
|
export declare const OIDC_CLIENT_AUTH = "oidc-client";
|
|
9
|
+
export declare const GOOGLE_CLIENT_AUTH = "google-oauth";
|
|
10
|
+
export declare const GOOGLE_SERVICE = "google";
|
|
9
11
|
export declare const OIDC_GUARD = "guard:oidc";
|
|
10
12
|
export declare const OIDC_GUARD_CACHE = "resource:oidc-guard:cache";
|
|
11
13
|
export declare const DISPATCHER_OIDC_INIT = "dispatcher:oidc:init";
|
package/build/consts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,SAAS,CAAA;AAElC,eAAO,MAAM,aAAa,gBAAgB,CAAA;AAE1C,eAAO,MAAM,gBAAgB,sBAAsB,CAAA;AAE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AEtD,eAAO,MAAM,YAAY,uBAAuB,CAAA;AAEhD,eAAO,MAAM,SAAS,cAAc,CAAA"}
|
package/build/consts.js
CHANGED
|
@@ -6,6 +6,9 @@ export const OIDC_FLOW = 'oidc';
|
|
|
6
6
|
export const OIDC_AUTHEN_MODULE = 'iam-oidc-authen';
|
|
7
7
|
export const PROVIDER_INTERACTION = 'oidc-server:interaction';
|
|
8
8
|
export const OIDC_CLIENT_AUTH = 'oidc-client';
|
|
9
|
+
export const GOOGLE_CLIENT_AUTH = 'google-oauth';
|
|
10
|
+
// This constant is the name of oidc identity provider that is called service in the oidc provider config.
|
|
11
|
+
export const GOOGLE_SERVICE = 'google';
|
|
9
12
|
export const OIDC_GUARD = 'guard:oidc';
|
|
10
13
|
export const OIDC_GUARD_CACHE = 'resource:oidc-guard:cache';
|
|
11
14
|
export const DISPATCHER_OIDC_INIT = 'dispatcher:oidc:init';
|
package/build/consts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAA;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAA;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AAEnD,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAA;AAE7C,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAA;AAE/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAA;AAEnD,MAAM,CAAC,MAAM,oBAAoB,GAAG,yBAAyB,CAAA;AAE7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAA;AAE7C,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA;AAEtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAA;AAE3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAA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EhD,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA"}
|
package/build/guard.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config, Context, OidcGuard, OidcGuardOptions } from './types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CommonEntrypoint } from '@owlmeans/entrypoint';
|
|
3
3
|
export declare const makeOidcGuard: (opts?: OidcGuardOptions) => OidcGuard;
|
|
4
4
|
export declare const appendOidcGuard: <C extends Config, T extends Context<C>>(context: T, opts?: OidcGuardOptions) => T;
|
|
5
|
-
export declare const setupOidcGuard: (modules:
|
|
5
|
+
export declare const setupOidcGuard: (modules: CommonEntrypoint[], coguards?: string | string[]) => void;
|
|
6
6
|
//# sourceMappingURL=guard.d.ts.map
|
package/build/guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAsB,MAAM,YAAY,CAAA;AAElG,OAAO,KAAK,EAAqC,
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAsB,MAAM,YAAY,CAAA;AAElG,OAAO,KAAK,EAAqC,gBAAgB,EAAgB,MAAM,sBAAsB,CAAA;AAS7G,eAAO,MAAM,aAAa,GAAI,OAAO,gBAAgB,KAAG,SA4FvD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EACpE,SAAS,CAAC,EAAE,OAAO,gBAAgB,MAKpC,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,SAAS,gBAAgB,EAAE,EAAE,WAAW,MAAM,GAAG,MAAM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O,CAAC,UAAU,CAAC,CAAA;QACnC,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAsB,EAAE,CACvD,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC;IAC9B,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;IAC/B,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE,CAAC,KAAK,EAAwB,CAAA"}
|
package/build/modules.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const modules: import("@owlmeans/
|
|
1
|
+
export declare const modules: import("@owlmeans/entrypoint").CommonEntrypoint[];
|
|
2
2
|
//# sourceMappingURL=modules.d.ts.map
|
package/build/modules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,mDAUnB,CAAA"}
|
package/build/modules.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { body, filter,
|
|
1
|
+
import { body, filter, entrypoint } from '@owlmeans/entrypoint';
|
|
2
2
|
import { route, RouteMethod, backend } from '@owlmeans/route';
|
|
3
3
|
import { DISPATCHER_OIDC, DISPATCHER_OIDC_INIT } from './consts.js';
|
|
4
4
|
import { OIDCAuthInitParamsSchema, OIDCClientAuthPayloadSchema } from './models.js';
|
|
5
5
|
export const modules = [
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
entrypoint(route(DISPATCHER_OIDC_INIT, '/authenticate/oidc/init', backend(null, RouteMethod.POST)), filter(body(OIDCAuthInitParamsSchema))),
|
|
7
|
+
entrypoint(route(DISPATCHER_OIDC, '/authenticate/oidc/process', backend(null, RouteMethod.POST)), filter(body(OIDCClientAuthPayloadSchema)))
|
|
8
8
|
];
|
|
9
9
|
//# sourceMappingURL=modules.js.map
|
package/build/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAEnF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,UAAU,CACR,KAAK,CAAC,oBAAoB,EAAE,yBAAyB,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EACvF,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAEvC;IACD,UAAU,CACR,KAAK,CAAC,eAAe,EAAE,4BAA4B,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EACrF,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAC1C;CACF,CAAA"}
|
package/build/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AuthToken } from '@owlmeans/auth';
|
|
2
2
|
import type { AuthorizationService } from '@owlmeans/auth-common';
|
|
3
3
|
import type { BasicConfig, BasicContext } from '@owlmeans/context';
|
|
4
|
-
import type { GuardService } from '@owlmeans/
|
|
4
|
+
import type { GuardService } from '@owlmeans/entrypoint';
|
|
5
5
|
export interface Config extends BasicConfig {
|
|
6
6
|
}
|
|
7
7
|
export interface Context<C extends Config = Config> extends BasicContext<C> {
|
|
@@ -32,7 +32,11 @@ export interface OidcProviderDescriptor {
|
|
|
32
32
|
basePath?: string;
|
|
33
33
|
clientId: string;
|
|
34
34
|
secret?: string;
|
|
35
|
+
redirectUri?: string;
|
|
35
36
|
extraScopes?: string;
|
|
37
|
+
authEndpoint?: string;
|
|
38
|
+
tokenEndpoint?: string;
|
|
39
|
+
userinfoEndpoint?: string;
|
|
36
40
|
idOverride?: string;
|
|
37
41
|
def?: boolean;
|
|
38
42
|
}
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,MAAM,WAAW,MAAO,SAAQ,WAAW;CAAI;AAC/C,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;CAAI;AAE/E,MAAM,WAAW,gBAAgB;IA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
+
"version": "0.1.3",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"build": "tsc -b",
|
|
@@ -20,22 +21,23 @@
|
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@owlmeans/auth": "^0.1.
|
|
24
|
-
"@owlmeans/auth-common": "^0.1.
|
|
25
|
-
"@owlmeans/basic-envelope": "^0.1.
|
|
26
|
-
"@owlmeans/config": "^0.1.
|
|
27
|
-
"@owlmeans/context": "^0.1.
|
|
28
|
-
"@owlmeans/
|
|
29
|
-
"@owlmeans/resource": "^0.1.
|
|
30
|
-
"@owlmeans/route": "^0.1.
|
|
24
|
+
"@owlmeans/auth": "^0.1.3",
|
|
25
|
+
"@owlmeans/auth-common": "^0.1.3",
|
|
26
|
+
"@owlmeans/basic-envelope": "^0.1.3",
|
|
27
|
+
"@owlmeans/config": "^0.1.3",
|
|
28
|
+
"@owlmeans/context": "^0.1.3",
|
|
29
|
+
"@owlmeans/entrypoint": "^0.1.3",
|
|
30
|
+
"@owlmeans/resource": "^0.1.3",
|
|
31
|
+
"@owlmeans/route": "^0.1.3"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"ajv": "*"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@owlmeans/dep-config": "workspace:*",
|
|
36
38
|
"nodemon": "^3.1.11",
|
|
37
39
|
"npm-check": "^6.0.1",
|
|
38
|
-
"typescript": "^
|
|
40
|
+
"typescript": "^6.0.2"
|
|
39
41
|
},
|
|
40
42
|
"publishConfig": {
|
|
41
43
|
"access": "public"
|
package/src/consts.ts
CHANGED
|
@@ -15,6 +15,11 @@ export const PROVIDER_INTERACTION = 'oidc-server:interaction'
|
|
|
15
15
|
|
|
16
16
|
export const OIDC_CLIENT_AUTH = 'oidc-client'
|
|
17
17
|
|
|
18
|
+
export const GOOGLE_CLIENT_AUTH = 'google-oauth'
|
|
19
|
+
|
|
20
|
+
// This constant is the name of oidc identity provider that is called service in the oidc provider config.
|
|
21
|
+
export const GOOGLE_SERVICE = 'google'
|
|
22
|
+
|
|
18
23
|
export const OIDC_GUARD = 'guard:oidc'
|
|
19
24
|
|
|
20
25
|
export const OIDC_GUARD_CACHE = 'resource:oidc-guard:cache'
|
package/src/guard.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createService } from '@owlmeans/context'
|
|
2
2
|
import type { Config, Context, OidcGuard, OidcGuardOptions, WrappedOIDCService } from './types.js'
|
|
3
3
|
import { OIDC_GUARD, OIDC_WRAPPED_TOKEN, WRAPPED_OIDC } from './consts.js'
|
|
4
|
-
import type { AbstractRequest, AbstractResponse,
|
|
4
|
+
import type { AbstractRequest, AbstractResponse, CommonEntrypoint, GuardService } from '@owlmeans/entrypoint'
|
|
5
5
|
import { DEFAULT_GUARD, TOKEN_UPDATE } from '@owlmeans/auth-common'
|
|
6
6
|
import { AUTH_HEADER, type Auth, AuthToken, AuthorizationError } from '@owlmeans/auth'
|
|
7
7
|
import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope'
|
|
@@ -112,7 +112,7 @@ export const appendOidcGuard = <C extends Config, T extends Context<C>>(
|
|
|
112
112
|
return context
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
export const setupOidcGuard = (modules:
|
|
115
|
+
export const setupOidcGuard = (modules: CommonEntrypoint[], coguards?: string | string[]) => {
|
|
116
116
|
modules.push(...oidcModules)
|
|
117
117
|
coguards = Array.isArray(coguards) ? coguards : [coguards ?? DEFAULT_GUARD]
|
|
118
118
|
|
package/src/modules.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { body, filter,
|
|
1
|
+
import { body, filter, entrypoint } from '@owlmeans/entrypoint'
|
|
2
2
|
import { route, RouteMethod, backend } from '@owlmeans/route'
|
|
3
3
|
import { DISPATCHER_OIDC, DISPATCHER_OIDC_INIT } from './consts.js'
|
|
4
4
|
import { OIDCAuthInitParamsSchema, OIDCClientAuthPayloadSchema } from './models.js'
|
|
5
5
|
|
|
6
6
|
export const modules = [
|
|
7
|
-
|
|
7
|
+
entrypoint(
|
|
8
8
|
route(DISPATCHER_OIDC_INIT, '/authenticate/oidc/init', backend(null, RouteMethod.POST)),
|
|
9
9
|
filter(body(OIDCAuthInitParamsSchema))
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
),
|
|
12
|
-
|
|
12
|
+
entrypoint(
|
|
13
13
|
route(DISPATCHER_OIDC, '/authenticate/oidc/process', backend(null, RouteMethod.POST)),
|
|
14
14
|
filter(body(OIDCClientAuthPayloadSchema))
|
|
15
15
|
)
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AuthToken } from '@owlmeans/auth'
|
|
2
2
|
import type { AuthorizationService } from '@owlmeans/auth-common'
|
|
3
3
|
import type { BasicConfig, BasicContext } from '@owlmeans/context'
|
|
4
|
-
import type { GuardService } from '@owlmeans/
|
|
4
|
+
import type { GuardService } from '@owlmeans/entrypoint'
|
|
5
5
|
|
|
6
6
|
export interface Config extends BasicConfig { }
|
|
7
7
|
export interface Context<C extends Config = Config> extends BasicContext<C> { }
|
|
@@ -37,7 +37,11 @@ export interface OidcProviderDescriptor {
|
|
|
37
37
|
basePath?: string
|
|
38
38
|
clientId: string
|
|
39
39
|
secret?: string
|
|
40
|
+
redirectUri?: string
|
|
40
41
|
extraScopes?: string
|
|
42
|
+
authEndpoint?: string
|
|
43
|
+
tokenEndpoint?: string
|
|
44
|
+
userinfoEndpoint?: string
|
|
41
45
|
idOverride?: string
|
|
42
46
|
// This flag works only on client side. It specifies a default relying party
|
|
43
47
|
def?: boolean
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": [
|
|
3
|
-
"
|
|
3
|
+
"@owlmeans/dep-config/tsconfig.base.json",
|
|
4
|
+
"@owlmeans/dep-config/tsconfig.server.json"
|
|
4
5
|
],
|
|
5
6
|
"compilerOptions": {
|
|
6
|
-
"rootDir": "./src/",
|
|
7
|
-
"outDir": "./build/"
|
|
8
|
-
"moduleResolution": "Bundler",
|
|
7
|
+
"rootDir": "./src/",
|
|
8
|
+
"outDir": "./build/"
|
|
9
9
|
},
|
|
10
10
|
"exclude": [
|
|
11
11
|
"./dist/**/*",
|
|
12
12
|
"./build/**/*",
|
|
13
13
|
"./*.ts"
|
|
14
14
|
]
|
|
15
|
-
}
|
|
15
|
+
}
|