@morojs/moro 1.0.3 → 1.2.0
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/README.md +57 -2
- package/dist/core/auth/morojs-adapter.d.ts +94 -0
- package/dist/core/auth/morojs-adapter.js +288 -0
- package/dist/core/auth/morojs-adapter.js.map +1 -0
- package/dist/core/config/file-loader.d.ts +18 -0
- package/dist/core/config/file-loader.js +345 -0
- package/dist/core/config/file-loader.js.map +1 -0
- package/dist/core/config/index.d.ts +6 -0
- package/dist/core/config/index.js +15 -0
- package/dist/core/config/index.js.map +1 -1
- package/dist/core/config/loader.d.ts +2 -1
- package/dist/core/config/loader.js +15 -2
- package/dist/core/config/loader.js.map +1 -1
- package/dist/core/config/utils.js +50 -3
- package/dist/core/config/utils.js.map +1 -1
- package/dist/core/http/http-server.d.ts +2 -0
- package/dist/core/http/http-server.js +52 -9
- package/dist/core/http/http-server.js.map +1 -1
- package/dist/core/middleware/built-in/auth-helpers.d.ts +124 -0
- package/dist/core/middleware/built-in/auth-helpers.js +338 -0
- package/dist/core/middleware/built-in/auth-helpers.js.map +1 -0
- package/dist/core/middleware/built-in/auth-providers.d.ts +125 -0
- package/dist/core/middleware/built-in/auth-providers.js +394 -0
- package/dist/core/middleware/built-in/auth-providers.js.map +1 -0
- package/dist/core/middleware/built-in/auth.d.ts +29 -1
- package/dist/core/middleware/built-in/auth.js +259 -16
- package/dist/core/middleware/built-in/auth.js.map +1 -1
- package/dist/core/middleware/built-in/index.d.ts +3 -1
- package/dist/core/middleware/built-in/index.js +19 -1
- package/dist/core/middleware/built-in/index.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/moro.d.ts +1 -0
- package/dist/moro.js +19 -1
- package/dist/moro.js.map +1 -1
- package/dist/types/auth.d.ts +367 -0
- package/dist/types/auth.js +28 -0
- package/dist/types/auth.js.map +1 -0
- package/package.json +6 -2
- package/src/core/auth/README.md +339 -0
- package/src/core/auth/morojs-adapter.ts +402 -0
- package/src/core/config/file-loader.ts +398 -0
- package/src/core/config/index.ts +18 -0
- package/src/core/config/loader.ts +18 -2
- package/src/core/config/utils.ts +53 -3
- package/src/core/http/http-server.ts +61 -10
- package/src/core/middleware/built-in/auth-helpers.ts +401 -0
- package/src/core/middleware/built-in/auth-providers.ts +480 -0
- package/src/core/middleware/built-in/auth.ts +306 -16
- package/src/core/middleware/built-in/index.ts +22 -0
- package/src/index.ts +30 -1
- package/src/moro.ts +29 -1
- package/src/types/auth.ts +440 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
// Extended Auth.js Provider Configurations
|
|
2
|
+
import { AuthProvider } from '../../../types/auth';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Popular OAuth Providers for Auth.js
|
|
6
|
+
* These extend the basic providers with more options and popular services
|
|
7
|
+
*/
|
|
8
|
+
export const extendedProviders = {
|
|
9
|
+
// Enhanced GitHub provider with more options
|
|
10
|
+
github: (options: {
|
|
11
|
+
clientId: string;
|
|
12
|
+
clientSecret: string;
|
|
13
|
+
scope?: string;
|
|
14
|
+
allowSignup?: boolean;
|
|
15
|
+
}): AuthProvider => ({
|
|
16
|
+
id: 'github',
|
|
17
|
+
name: 'GitHub',
|
|
18
|
+
type: 'oauth' as const,
|
|
19
|
+
authorization: {
|
|
20
|
+
url: 'https://github.com/login/oauth/authorize',
|
|
21
|
+
params: {
|
|
22
|
+
scope: options.scope || 'read:user user:email',
|
|
23
|
+
allow_signup: options.allowSignup ?? true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
token: 'https://github.com/login/oauth/access_token',
|
|
27
|
+
userinfo: 'https://api.github.com/user',
|
|
28
|
+
clientId: options.clientId,
|
|
29
|
+
clientSecret: options.clientSecret,
|
|
30
|
+
profile: profile => ({
|
|
31
|
+
id: profile.id.toString(),
|
|
32
|
+
name: profile.name || profile.login,
|
|
33
|
+
email: profile.email,
|
|
34
|
+
image: profile.avatar_url,
|
|
35
|
+
username: profile.login,
|
|
36
|
+
}),
|
|
37
|
+
}),
|
|
38
|
+
|
|
39
|
+
// Enhanced Google provider
|
|
40
|
+
google: (options: {
|
|
41
|
+
clientId: string;
|
|
42
|
+
clientSecret: string;
|
|
43
|
+
scope?: string;
|
|
44
|
+
hostedDomain?: string;
|
|
45
|
+
}): AuthProvider => ({
|
|
46
|
+
id: 'google',
|
|
47
|
+
name: 'Google',
|
|
48
|
+
type: 'oauth' as const,
|
|
49
|
+
authorization: {
|
|
50
|
+
url: 'https://accounts.google.com/oauth/authorize',
|
|
51
|
+
params: {
|
|
52
|
+
scope: options.scope || 'openid email profile',
|
|
53
|
+
response_type: 'code',
|
|
54
|
+
...(options.hostedDomain && { hd: options.hostedDomain }),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
token: 'https://oauth2.googleapis.com/token',
|
|
58
|
+
userinfo: 'https://www.googleapis.com/oauth2/v2/userinfo',
|
|
59
|
+
clientId: options.clientId,
|
|
60
|
+
clientSecret: options.clientSecret,
|
|
61
|
+
profile: profile => ({
|
|
62
|
+
id: profile.id,
|
|
63
|
+
name: profile.name,
|
|
64
|
+
email: profile.email,
|
|
65
|
+
image: profile.picture,
|
|
66
|
+
emailVerified: profile.verified_email,
|
|
67
|
+
}),
|
|
68
|
+
}),
|
|
69
|
+
|
|
70
|
+
// Microsoft/Azure AD provider
|
|
71
|
+
microsoft: (options: {
|
|
72
|
+
clientId: string;
|
|
73
|
+
clientSecret: string;
|
|
74
|
+
tenant?: string;
|
|
75
|
+
scope?: string;
|
|
76
|
+
}): AuthProvider => ({
|
|
77
|
+
id: 'microsoft',
|
|
78
|
+
name: 'Microsoft',
|
|
79
|
+
type: 'oauth' as const,
|
|
80
|
+
authorization: {
|
|
81
|
+
url: `https://login.microsoftonline.com/${options.tenant || 'common'}/oauth2/v2.0/authorize`,
|
|
82
|
+
params: {
|
|
83
|
+
scope: options.scope || 'openid email profile',
|
|
84
|
+
response_type: 'code',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
token: `https://login.microsoftonline.com/${options.tenant || 'common'}/oauth2/v2.0/token`,
|
|
88
|
+
userinfo: 'https://graph.microsoft.com/oidc/userinfo',
|
|
89
|
+
clientId: options.clientId,
|
|
90
|
+
clientSecret: options.clientSecret,
|
|
91
|
+
profile: profile => ({
|
|
92
|
+
id: profile.sub,
|
|
93
|
+
name: profile.name,
|
|
94
|
+
email: profile.email,
|
|
95
|
+
image: profile.picture,
|
|
96
|
+
}),
|
|
97
|
+
}),
|
|
98
|
+
|
|
99
|
+
// Apple provider
|
|
100
|
+
apple: (options: { clientId: string; clientSecret: string; scope?: string }): AuthProvider => ({
|
|
101
|
+
id: 'apple',
|
|
102
|
+
name: 'Apple',
|
|
103
|
+
type: 'oauth' as const,
|
|
104
|
+
authorization: {
|
|
105
|
+
url: 'https://appleid.apple.com/auth/authorize',
|
|
106
|
+
params: {
|
|
107
|
+
scope: options.scope || 'name email',
|
|
108
|
+
response_mode: 'form_post',
|
|
109
|
+
response_type: 'code',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
token: 'https://appleid.apple.com/auth/token',
|
|
113
|
+
clientId: options.clientId,
|
|
114
|
+
clientSecret: options.clientSecret,
|
|
115
|
+
profile: (profile, tokens) => ({
|
|
116
|
+
id: profile.sub,
|
|
117
|
+
name: profile.name ? `${profile.name.firstName} ${profile.name.lastName}` : null,
|
|
118
|
+
email: profile.email,
|
|
119
|
+
emailVerified: profile.email_verified === 'true',
|
|
120
|
+
}),
|
|
121
|
+
}),
|
|
122
|
+
|
|
123
|
+
// LinkedIn provider
|
|
124
|
+
linkedin: (options: {
|
|
125
|
+
clientId: string;
|
|
126
|
+
clientSecret: string;
|
|
127
|
+
scope?: string;
|
|
128
|
+
}): AuthProvider => ({
|
|
129
|
+
id: 'linkedin',
|
|
130
|
+
name: 'LinkedIn',
|
|
131
|
+
type: 'oauth' as const,
|
|
132
|
+
authorization: {
|
|
133
|
+
url: 'https://www.linkedin.com/oauth/v2/authorization',
|
|
134
|
+
params: {
|
|
135
|
+
scope: options.scope || 'r_liteprofile r_emailaddress',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
token: 'https://www.linkedin.com/oauth/v2/accessToken',
|
|
139
|
+
userinfo: 'https://api.linkedin.com/v2/me',
|
|
140
|
+
clientId: options.clientId,
|
|
141
|
+
clientSecret: options.clientSecret,
|
|
142
|
+
profile: profile => ({
|
|
143
|
+
id: profile.id,
|
|
144
|
+
name: `${profile.localizedFirstName} ${profile.localizedLastName}`,
|
|
145
|
+
email: profile.emailAddress,
|
|
146
|
+
image: profile.profilePicture?.['displayImage~']?.elements?.[0]?.identifiers?.[0]?.identifier,
|
|
147
|
+
}),
|
|
148
|
+
}),
|
|
149
|
+
|
|
150
|
+
// Facebook provider
|
|
151
|
+
facebook: (options: {
|
|
152
|
+
clientId: string;
|
|
153
|
+
clientSecret: string;
|
|
154
|
+
scope?: string;
|
|
155
|
+
}): AuthProvider => ({
|
|
156
|
+
id: 'facebook',
|
|
157
|
+
name: 'Facebook',
|
|
158
|
+
type: 'oauth' as const,
|
|
159
|
+
authorization: {
|
|
160
|
+
url: 'https://www.facebook.com/v18.0/dialog/oauth',
|
|
161
|
+
params: {
|
|
162
|
+
scope: options.scope || 'email public_profile',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
token: 'https://graph.facebook.com/v18.0/oauth/access_token',
|
|
166
|
+
userinfo: 'https://graph.facebook.com/me?fields=id,name,email,picture',
|
|
167
|
+
clientId: options.clientId,
|
|
168
|
+
clientSecret: options.clientSecret,
|
|
169
|
+
profile: profile => ({
|
|
170
|
+
id: profile.id,
|
|
171
|
+
name: profile.name,
|
|
172
|
+
email: profile.email,
|
|
173
|
+
image: profile.picture?.data?.url,
|
|
174
|
+
}),
|
|
175
|
+
}),
|
|
176
|
+
|
|
177
|
+
// Twitter/X provider
|
|
178
|
+
twitter: (options: {
|
|
179
|
+
clientId: string;
|
|
180
|
+
clientSecret: string;
|
|
181
|
+
version?: '1.0a' | '2.0';
|
|
182
|
+
}): AuthProvider => ({
|
|
183
|
+
id: 'twitter',
|
|
184
|
+
name: 'Twitter',
|
|
185
|
+
type: 'oauth' as const,
|
|
186
|
+
authorization: 'https://twitter.com/i/oauth2/authorize',
|
|
187
|
+
token: 'https://api.twitter.com/2/oauth2/token',
|
|
188
|
+
userinfo: 'https://api.twitter.com/2/users/me',
|
|
189
|
+
clientId: options.clientId,
|
|
190
|
+
clientSecret: options.clientSecret,
|
|
191
|
+
profile: profile => ({
|
|
192
|
+
id: profile.data.id,
|
|
193
|
+
name: profile.data.name,
|
|
194
|
+
username: profile.data.username,
|
|
195
|
+
image: profile.data.profile_image_url,
|
|
196
|
+
}),
|
|
197
|
+
}),
|
|
198
|
+
|
|
199
|
+
// Slack provider
|
|
200
|
+
slack: (options: { clientId: string; clientSecret: string; scope?: string }): AuthProvider => ({
|
|
201
|
+
id: 'slack',
|
|
202
|
+
name: 'Slack',
|
|
203
|
+
type: 'oauth' as const,
|
|
204
|
+
authorization: {
|
|
205
|
+
url: 'https://slack.com/oauth/v2/authorize',
|
|
206
|
+
params: {
|
|
207
|
+
user_scope: options.scope || 'identity.basic identity.email identity.avatar',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
token: 'https://slack.com/api/oauth.v2.access',
|
|
211
|
+
userinfo: 'https://slack.com/api/users.identity',
|
|
212
|
+
clientId: options.clientId,
|
|
213
|
+
clientSecret: options.clientSecret,
|
|
214
|
+
profile: profile => ({
|
|
215
|
+
id: profile.user.id,
|
|
216
|
+
name: profile.user.name,
|
|
217
|
+
email: profile.user.email,
|
|
218
|
+
image: profile.user.image_192,
|
|
219
|
+
}),
|
|
220
|
+
}),
|
|
221
|
+
|
|
222
|
+
// GitLab provider
|
|
223
|
+
gitlab: (options: {
|
|
224
|
+
clientId: string;
|
|
225
|
+
clientSecret: string;
|
|
226
|
+
domain?: string;
|
|
227
|
+
scope?: string;
|
|
228
|
+
}): AuthProvider => ({
|
|
229
|
+
id: 'gitlab',
|
|
230
|
+
name: 'GitLab',
|
|
231
|
+
type: 'oauth' as const,
|
|
232
|
+
authorization: {
|
|
233
|
+
url: `${options.domain || 'https://gitlab.com'}/oauth/authorize`,
|
|
234
|
+
params: {
|
|
235
|
+
scope: options.scope || 'read_user',
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
token: `${options.domain || 'https://gitlab.com'}/oauth/token`,
|
|
239
|
+
userinfo: `${options.domain || 'https://gitlab.com'}/api/v4/user`,
|
|
240
|
+
clientId: options.clientId,
|
|
241
|
+
clientSecret: options.clientSecret,
|
|
242
|
+
profile: profile => ({
|
|
243
|
+
id: profile.id.toString(),
|
|
244
|
+
name: profile.name,
|
|
245
|
+
email: profile.email,
|
|
246
|
+
image: profile.avatar_url,
|
|
247
|
+
username: profile.username,
|
|
248
|
+
}),
|
|
249
|
+
}),
|
|
250
|
+
|
|
251
|
+
// Spotify provider
|
|
252
|
+
spotify: (options: { clientId: string; clientSecret: string; scope?: string }): AuthProvider => ({
|
|
253
|
+
id: 'spotify',
|
|
254
|
+
name: 'Spotify',
|
|
255
|
+
type: 'oauth' as const,
|
|
256
|
+
authorization: {
|
|
257
|
+
url: 'https://accounts.spotify.com/authorize',
|
|
258
|
+
params: {
|
|
259
|
+
scope: options.scope || 'user-read-email user-read-private',
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
token: 'https://accounts.spotify.com/api/token',
|
|
263
|
+
userinfo: 'https://api.spotify.com/v1/me',
|
|
264
|
+
clientId: options.clientId,
|
|
265
|
+
clientSecret: options.clientSecret,
|
|
266
|
+
profile: profile => ({
|
|
267
|
+
id: profile.id,
|
|
268
|
+
name: profile.display_name,
|
|
269
|
+
email: profile.email,
|
|
270
|
+
image: profile.images?.[0]?.url,
|
|
271
|
+
}),
|
|
272
|
+
}),
|
|
273
|
+
|
|
274
|
+
// Twitch provider
|
|
275
|
+
twitch: (options: { clientId: string; clientSecret: string; scope?: string }): AuthProvider => ({
|
|
276
|
+
id: 'twitch',
|
|
277
|
+
name: 'Twitch',
|
|
278
|
+
type: 'oauth' as const,
|
|
279
|
+
authorization: {
|
|
280
|
+
url: 'https://id.twitch.tv/oauth2/authorize',
|
|
281
|
+
params: {
|
|
282
|
+
scope: options.scope || 'user:read:email',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
token: 'https://id.twitch.tv/oauth2/token',
|
|
286
|
+
userinfo: 'https://api.twitch.tv/helix/users',
|
|
287
|
+
clientId: options.clientId,
|
|
288
|
+
clientSecret: options.clientSecret,
|
|
289
|
+
profile: profile => ({
|
|
290
|
+
id: profile.data[0].id,
|
|
291
|
+
name: profile.data[0].display_name,
|
|
292
|
+
email: profile.data[0].email,
|
|
293
|
+
image: profile.data[0].profile_image_url,
|
|
294
|
+
username: profile.data[0].login,
|
|
295
|
+
}),
|
|
296
|
+
}),
|
|
297
|
+
|
|
298
|
+
// Notion provider
|
|
299
|
+
notion: (options: { clientId: string; clientSecret: string }): AuthProvider => ({
|
|
300
|
+
id: 'notion',
|
|
301
|
+
name: 'Notion',
|
|
302
|
+
type: 'oauth' as const,
|
|
303
|
+
authorization: 'https://api.notion.com/v1/oauth/authorize',
|
|
304
|
+
token: 'https://api.notion.com/v1/oauth/token',
|
|
305
|
+
userinfo: 'https://api.notion.com/v1/users/me',
|
|
306
|
+
clientId: options.clientId,
|
|
307
|
+
clientSecret: options.clientSecret,
|
|
308
|
+
profile: profile => ({
|
|
309
|
+
id: profile.id,
|
|
310
|
+
name: profile.name,
|
|
311
|
+
email: profile.person?.email,
|
|
312
|
+
image: profile.avatar_url,
|
|
313
|
+
}),
|
|
314
|
+
}),
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Enterprise/SAML providers
|
|
319
|
+
*/
|
|
320
|
+
export const enterpriseProviders = {
|
|
321
|
+
// Generic SAML provider
|
|
322
|
+
saml: (options: {
|
|
323
|
+
name: string;
|
|
324
|
+
entryPoint: string;
|
|
325
|
+
issuer: string;
|
|
326
|
+
cert: string;
|
|
327
|
+
callbackUrl?: string;
|
|
328
|
+
}): AuthProvider => ({
|
|
329
|
+
id: 'saml',
|
|
330
|
+
name: options.name,
|
|
331
|
+
type: 'oauth' as const,
|
|
332
|
+
authorization: options.entryPoint,
|
|
333
|
+
clientId: options.issuer,
|
|
334
|
+
// SAML-specific configuration would go here
|
|
335
|
+
entryPoint: options.entryPoint,
|
|
336
|
+
issuer: options.issuer,
|
|
337
|
+
cert: options.cert,
|
|
338
|
+
callbackUrl: options.callbackUrl,
|
|
339
|
+
}),
|
|
340
|
+
|
|
341
|
+
// Okta provider
|
|
342
|
+
okta: (options: {
|
|
343
|
+
clientId: string;
|
|
344
|
+
clientSecret: string;
|
|
345
|
+
domain: string;
|
|
346
|
+
authorizationServerId?: string;
|
|
347
|
+
}): AuthProvider => ({
|
|
348
|
+
id: 'okta',
|
|
349
|
+
name: 'Okta',
|
|
350
|
+
type: 'oidc' as const,
|
|
351
|
+
issuer: `${options.domain}/oauth2/${options.authorizationServerId || 'default'}`,
|
|
352
|
+
clientId: options.clientId,
|
|
353
|
+
clientSecret: options.clientSecret,
|
|
354
|
+
profile: profile => ({
|
|
355
|
+
id: profile.sub,
|
|
356
|
+
name: profile.name,
|
|
357
|
+
email: profile.email,
|
|
358
|
+
username: profile.preferred_username,
|
|
359
|
+
}),
|
|
360
|
+
}),
|
|
361
|
+
|
|
362
|
+
// Auth0 provider
|
|
363
|
+
auth0: (options: {
|
|
364
|
+
clientId: string;
|
|
365
|
+
clientSecret: string;
|
|
366
|
+
domain: string;
|
|
367
|
+
audience?: string;
|
|
368
|
+
}): AuthProvider => ({
|
|
369
|
+
id: 'auth0',
|
|
370
|
+
name: 'Auth0',
|
|
371
|
+
type: 'oidc' as const,
|
|
372
|
+
issuer: `https://${options.domain}`,
|
|
373
|
+
clientId: options.clientId,
|
|
374
|
+
clientSecret: options.clientSecret,
|
|
375
|
+
authorization: {
|
|
376
|
+
url: `https://${options.domain}/authorize`,
|
|
377
|
+
params: {
|
|
378
|
+
audience: options.audience,
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
profile: profile => ({
|
|
382
|
+
id: profile.sub,
|
|
383
|
+
name: profile.name,
|
|
384
|
+
email: profile.email,
|
|
385
|
+
image: profile.picture,
|
|
386
|
+
emailVerified: profile.email_verified,
|
|
387
|
+
}),
|
|
388
|
+
}),
|
|
389
|
+
|
|
390
|
+
// AWS Cognito provider
|
|
391
|
+
cognito: (options: {
|
|
392
|
+
clientId: string;
|
|
393
|
+
clientSecret: string;
|
|
394
|
+
domain: string;
|
|
395
|
+
region?: string;
|
|
396
|
+
}): AuthProvider => ({
|
|
397
|
+
id: 'cognito',
|
|
398
|
+
name: 'AWS Cognito',
|
|
399
|
+
type: 'oidc' as const,
|
|
400
|
+
issuer: `https://cognito-idp.${options.region || 'us-east-1'}.amazonaws.com/${options.domain}`,
|
|
401
|
+
clientId: options.clientId,
|
|
402
|
+
clientSecret: options.clientSecret,
|
|
403
|
+
profile: profile => ({
|
|
404
|
+
id: profile.sub,
|
|
405
|
+
name: profile.name,
|
|
406
|
+
email: profile.email,
|
|
407
|
+
username: profile['cognito:username'],
|
|
408
|
+
emailVerified: profile.email_verified,
|
|
409
|
+
}),
|
|
410
|
+
}),
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Helper function to create custom OAuth provider
|
|
415
|
+
*/
|
|
416
|
+
export function createCustomOAuthProvider(config: {
|
|
417
|
+
id: string;
|
|
418
|
+
name: string;
|
|
419
|
+
clientId: string;
|
|
420
|
+
clientSecret: string;
|
|
421
|
+
authorizationUrl: string;
|
|
422
|
+
tokenUrl: string;
|
|
423
|
+
userinfoUrl: string;
|
|
424
|
+
scope?: string;
|
|
425
|
+
profileMapper?: (profile: any) => any;
|
|
426
|
+
}): AuthProvider {
|
|
427
|
+
return {
|
|
428
|
+
id: config.id,
|
|
429
|
+
name: config.name,
|
|
430
|
+
type: 'oauth' as const,
|
|
431
|
+
authorization: {
|
|
432
|
+
url: config.authorizationUrl,
|
|
433
|
+
params: {
|
|
434
|
+
scope: config.scope || 'openid email profile',
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
token: config.tokenUrl,
|
|
438
|
+
userinfo: config.userinfoUrl,
|
|
439
|
+
clientId: config.clientId,
|
|
440
|
+
clientSecret: config.clientSecret,
|
|
441
|
+
profile:
|
|
442
|
+
config.profileMapper ||
|
|
443
|
+
(profile => ({
|
|
444
|
+
id: profile.id || profile.sub,
|
|
445
|
+
name: profile.name,
|
|
446
|
+
email: profile.email,
|
|
447
|
+
image: profile.picture || profile.avatar_url,
|
|
448
|
+
})),
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Helper function to create custom OIDC provider
|
|
454
|
+
*/
|
|
455
|
+
export function createCustomOIDCProvider(config: {
|
|
456
|
+
id: string;
|
|
457
|
+
name: string;
|
|
458
|
+
clientId: string;
|
|
459
|
+
clientSecret: string;
|
|
460
|
+
issuer: string;
|
|
461
|
+
profileMapper?: (profile: any) => any;
|
|
462
|
+
}): AuthProvider {
|
|
463
|
+
return {
|
|
464
|
+
id: config.id,
|
|
465
|
+
name: config.name,
|
|
466
|
+
type: 'oidc' as const,
|
|
467
|
+
issuer: config.issuer,
|
|
468
|
+
clientId: config.clientId,
|
|
469
|
+
clientSecret: config.clientSecret,
|
|
470
|
+
profile:
|
|
471
|
+
config.profileMapper ||
|
|
472
|
+
(profile => ({
|
|
473
|
+
id: profile.sub,
|
|
474
|
+
name: profile.name,
|
|
475
|
+
email: profile.email,
|
|
476
|
+
image: profile.picture,
|
|
477
|
+
emailVerified: profile.email_verified,
|
|
478
|
+
})),
|
|
479
|
+
};
|
|
480
|
+
}
|