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

[providers]: Add FusionAuth provider #599

Merged
merged 2 commits into from
Aug 29, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/providers/fusionauth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default (options) => {
let authorizationUrl = `https://${options.domain}/oauth2/authorize?response_type=code`
if (options.tenantId) {
authorizationUrl += `&tenantId=${options.tenantId}`
}

return {
id: 'fusionauth',
name: 'FusionAuth',
type: 'oauth',
version: '2.0',
scope: 'openid',
params: { grant_type: 'authorization_code' },
accessTokenUrl: `https://${options.domain}/oauth2/token`,
authorizationUrl,
profileUrl: `https://${options.domain}/oauth2/userinfo`,
profile: (profile) => {
return {
id: profile.sub,
name: profile.name,
email: profile.email,
image: profile.picture
}
},
...options
}
}
2 changes: 2 additions & 0 deletions src/providers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Cognito from './cognito'
import Discord from './discord'
import Email from './email'
import Facebook from './facebook'
import FusionAuth from './fusionauth'
import GitHub from './github'
import GitLab from './gitlab'
import Google from './google'
Expand All @@ -32,6 +33,7 @@ export default {
Discord,
Email,
Facebook,
FusionAuth,
GitHub,
GitLab,
Google,
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, Auth0, Google, Battle.net, Box, AWS Cognito, Discord, Facebook, 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, 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 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
46 changes: 46 additions & 0 deletions www/docs/providers/fusionauth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
id: fusionauth
title: FusionAuth
---

## Documentation

https://fusionauth.io/docs/v1/tech/oauth/

## Example

```js
import Providers from `next-auth/providers`
...
providers: [
Providers.FusionAuth({
id: "fusionauth",
name: "FusionAuth",
domain: process.env.FUSIONAUTH_DOMAIN,
clientId: process.env.FUSIONAUTH_CLIENT_ID,
clientSecret: process.env.FUSIONAUTH_SECRET,
tenantId: process.env.FUSIONAUTH_TENANT_ID // Only required if you're using multi-tenancy
}),
}
...
```

:::warning
If you're using multi-tenancy, you need to pass in the `tenantId` option to apply the proper theme.
:::

## Instructions

### Configuration

:::tip
An application can be created at https://your-fusionauth-server-url/admin/application.

For more information, follow the [FusionAuth 5-minute setup guide](https://fusionauth.io/docs/v1/tech/5-minute-setup-guide).
:::

In the OAuth settings for your application, configure the following.
* Redirect URL
- https://localhost:3000/api/auth/callback/fusionauth
* Enabled grants
- Make sure *Authorization Code* is enabled.
1 change: 1 addition & 0 deletions www/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
'providers/email',
'providers/credentials',
'providers/facebook',
'providers/fusionauth',
'providers/github',
'providers/gitlab',
'providers/google',
Expand Down