Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(provider): Add Azure Active Directory B2C #809

Merged
merged 6 commits into from
Dec 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/providers/azure-ad-b2c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default (options) => {
const tenant = options.tenantId ? options.tenantId : 'common'

return {
id: 'azure-ad-b2c',
name: 'Azure Active Directory B2C',
type: 'oauth',
version: '2.0',
params: {
grant_type: 'authorization_code'
},
accessTokenUrl: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/token`,
authorizationUrl: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/authorize?response_type=code&response_mode=query`,
profileUrl: 'https://graph.microsoft.com/v1.0/me/',
profile: (profile) => {
return {
id: profile.id,
name: profile.displayName,
email: profile.userPrincipalName
}
},
...options
}
}
2 changes: 2 additions & 0 deletions src/providers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Apple from './apple'
import Atlassian from './atlassian'
import Auth0 from './auth0'
import AzureADB2C from './azure-ad-b2c'
import Basecamp from './basecamp'
import BattleNet from './battlenet'
import Box from './box'
Expand All @@ -27,6 +28,7 @@ export default {
Atlassian,
Auth0,
Apple,
AzureADB2C,
Basecamp,
BattleNet,
Box,
Expand Down
1 change: 1 addition & 0 deletions www/docs/configuration/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ NextAuth.js is designed to work with any OAuth service, it supports OAuth 1.0, 1
* [Apple](/providers/apple)
* [Atlassian](/providers/atlassian)
* [Auth0](/providers/auth0)
* [Azure Active Directory B2C](/providers/azure-ad-b2c)
* [Basecamp](/providers/basecamp)
* [Battle.net](/providers/battlenet)
* [Box](/providers/box)
Expand Down
2 changes: 1 addition & 1 deletion www/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You can use also NextAuth.js with any database using a custom database adapter,

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

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.
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.

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).

Expand Down
28 changes: 28 additions & 0 deletions www/docs/providers/azure-ad-b2c.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
id: azure-ad-b2c
title: Azure Active Directory B2C
---

## Documentation

https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow

## Configuration

https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-tenant

## Example

```js
import Providers from 'next-auth/providers';
...
providers: [
Providers.AzureADB2C({
clientId: process.env.AZURE_CLIENT_ID,
clientSecret: process.env.AZURE_CLIENT_SECRET,
scope: 'offline_access User.Read',
tenantId: process.env.AZURE_TENANT_ID,
}),
]
...
```
1 change: 1 addition & 0 deletions www/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'providers/apple',
'providers/atlassian',
'providers/auth0',
'providers/azure-ad-b2c',
'providers/basecamp',
'providers/battle.net',
'providers/box',
Expand Down