File tree Expand file tree Collapse file tree 3 files changed +48
-44
lines changed Expand file tree Collapse file tree 3 files changed +48
-44
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import SpotifyProvider from "next-auth/providers/spotify"
22
22
import CognitoProvider from "next-auth/providers/cognito"
23
23
import SlackProvider from "next-auth/providers/slack"
24
24
import Okta from "next-auth/providers/okta"
25
+ import AzureB2C from "next-auth/providers/azure-ad-b2c"
25
26
26
27
// import { PrismaAdapter } from "@next-auth/prisma-adapter"
27
28
// import { PrismaClient } from "@prisma/client"
@@ -160,6 +161,12 @@ export default NextAuth({
160
161
clientId : process . env . SLACK_ID ,
161
162
clientSecret : process . env . SLACK_SECRET ,
162
163
} ) ,
164
+ AzureB2C ( {
165
+ clientId : process . env . AZURE_B2C_ID ,
166
+ clientSecret : process . env . AZURE_B2C_SECRET ,
167
+ tenantId : process . env . AZURE_B2C_TENANT_ID ,
168
+ primaryUserFlow : process . env . AZURE_B2C_PRIMARY_USER_FLOW ,
169
+ } ) ,
163
170
] ,
164
171
jwt : {
165
172
encryption : true ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { OAuthConfig , OAuthUserConfig } from "."
2
+
3
+ export interface AzureB2CProfile {
4
+ exp : number
5
+ nbf : number
6
+ ver : string
7
+ iss : string
8
+ sub : string
9
+ aud : string
10
+ iat : number
11
+ auth_time : number
12
+ oid : string
13
+ country : string
14
+ name : string
15
+ postalCode : string
16
+ emails : string [ ]
17
+ tfp : string
18
+ }
19
+
20
+ export default function AzureADB2C <
21
+ P extends Record < string , any > = AzureB2CProfile
22
+ > ( options : OAuthUserConfig < P > & { primaryUserFlow : string } ) : OAuthConfig < P > {
23
+ const { tenantId, primaryUserFlow } = options
24
+ return {
25
+ id : "azure-ad-b2c" ,
26
+ name : "Azure Active Directory B2C" ,
27
+ type : "oauth" ,
28
+ wellKnown : `https://${ tenantId } .b2clogin.com/${ tenantId } .onmicrosoft.com/${ primaryUserFlow } /v2.0/.well-known/openid-configuration` ,
29
+ idToken : true ,
30
+ profile ( profile ) {
31
+ return {
32
+ id : profile . sub ,
33
+ name : profile . name ,
34
+ email : profile . emails [ 0 ] ,
35
+ // TODO: Find out how to retrieve the profile picture
36
+ image : null ,
37
+ }
38
+ } ,
39
+ options,
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments