Skip to content

Commit 6e6a24a

Browse files
authored
feat(provider): Add Azure Active Directory B2C (#809)
* add provider: Microsoft * documentation * support no tenant setup * fix code style * chore: rename Microsoft provider to AzureADB2C * chore: alphabetical order in providers/index
1 parent 6f067be commit 6e6a24a

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
lines changed

src/providers/azure-ad-b2c.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default (options) => {
2+
const tenant = options.tenantId ? options.tenantId : 'common'
3+
4+
return {
5+
id: 'azure-ad-b2c',
6+
name: 'Azure Active Directory B2C',
7+
type: 'oauth',
8+
version: '2.0',
9+
params: {
10+
grant_type: 'authorization_code'
11+
},
12+
accessTokenUrl: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/token`,
13+
authorizationUrl: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/authorize?response_type=code&response_mode=query`,
14+
profileUrl: 'https://graph.microsoft.com/v1.0/me/',
15+
profile: (profile) => {
16+
return {
17+
id: profile.id,
18+
name: profile.displayName,
19+
email: profile.userPrincipalName
20+
}
21+
},
22+
...options
23+
}
24+
}

src/providers/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Apple from './apple'
22
import Atlassian from './atlassian'
33
import Auth0 from './auth0'
4+
import AzureADB2C from './azure-ad-b2c'
45
import Basecamp from './basecamp'
56
import BattleNet from './battlenet'
67
import Box from './box'
@@ -27,6 +28,7 @@ export default {
2728
Atlassian,
2829
Auth0,
2930
Apple,
31+
AzureADB2C,
3032
Basecamp,
3133
BattleNet,
3234
Box,

www/docs/configuration/providers.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1
1414
* [Apple](/providers/apple)
1515
* [Atlassian](/providers/atlassian)
1616
* [Auth0](/providers/auth0)
17+
* [Azure Active Directory B2C](/providers/azure-ad-b2c)
1718
* [Basecamp](/providers/basecamp)
1819
* [Battle.net](/providers/battlenet)
1920
* [Box](/providers/box)

www/docs/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ You can use also NextAuth.js with any database using a custom database adapter,
2323

2424
### What authentication services does NextAuth.js support?
2525

26-
NextAuth.js includes built-in support for signing in with Apple, Atlassian, Auth0, Google, Battle.net, Box, AWS Cognito, Discord, Facebook, FusionAuth, GitHub, GitLab, Google, Open ID Identity Server, Mixer, Okta, Slack, Spotify, Twitch, Twitter and Yandex.
26+
NextAuth.js includes built-in support for signing in with Apple, Atlassian, Auth0, Azure Active Directory B2C, Google, Battle.net, Box, AWS Cognito, Discord, Facebook, FusionAuth, GitHub, GitLab, Google, Open ID Identity Server, Mixer, Okta, Slack, Spotify, Twitch, Twitter and Yandex.
2727

2828
NextAuth.js also supports email for passwordless sign in, which is useful for account recovery or for people who are not able to use an account with the configured OAuth services (e.g. due to service outage, account suspension or otherwise becoming locked out of an account).
2929

www/docs/providers/azure-ad-b2c.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
id: azure-ad-b2c
3+
title: Azure Active Directory B2C
4+
---
5+
6+
## Documentation
7+
8+
https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
9+
10+
## Configuration
11+
12+
https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-tenant
13+
14+
## Example
15+
16+
```js
17+
import Providers from 'next-auth/providers';
18+
...
19+
providers: [
20+
Providers.AzureADB2C({
21+
clientId: process.env.AZURE_CLIENT_ID,
22+
clientSecret: process.env.AZURE_CLIENT_SECRET,
23+
scope: 'offline_access User.Read',
24+
tenantId: process.env.AZURE_TENANT_ID,
25+
}),
26+
]
27+
...
28+
```

www/sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
'providers/apple',
2727
'providers/atlassian',
2828
'providers/auth0',
29+
'providers/azure-ad-b2c',
2930
'providers/basecamp',
3031
'providers/battle.net',
3132
'providers/box',

0 commit comments

Comments
 (0)