-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Refactor SSO Configuration (docs v6) #2363
Draft
derrickmehaffy
wants to merge
1
commit into
v6/beta
Choose a base branch
from
v6/ssoRefactor
base: v6/beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
130 changes: 130 additions & 0 deletions
130
docusaurus/docs/dev-docs/configurations/sso-providers/auth0.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--- | ||
title: Auth0 - Admin SSO Provider | ||
description: Steps to configure Auth0 as a Strapi Admin SSO Provider | ||
displayed_sidebar: cmsSidebar | ||
tags: | ||
- auth0 | ||
- additional configuration | ||
- admin panel | ||
- configuration | ||
- Enterprise feature | ||
- SSO | ||
--- | ||
|
||
import SSOServerConfig from '/docs/snippets/configuration-sso-server.md' | ||
import SSOAdminConfig from '/docs/snippets/configuration-sso-admin.md' | ||
import SSOMiddlewaresConfig from '/docs/snippets/configuration-sso-middlewares.md' | ||
|
||
:::prerequisites | ||
|
||
- [Properly configure Strapi for SSO](#required-configuration-before-setting-up-sso) | ||
- Create your REPLACEME OAuth2 app by following the steps in the [TODO](https://TODO). | ||
- Gather the required information to set as environment variables in your Strapi project: | ||
- // TODO | ||
|
||
::: | ||
|
||
## Required configuration before setting up SSO | ||
|
||
### Server Configuration | ||
|
||
<SSOServerConfig /> | ||
|
||
### Admin Configuration | ||
|
||
<SSOAdminConfig /> | ||
|
||
### Middlewares Configuration | ||
|
||
<SSOMiddlewaresConfig /> | ||
|
||
## Provider Specific Notes | ||
|
||
### Scopes | ||
|
||
The TODO OAuth2 provider requires the following scopes, however additional scopes can be added as needed depending on your use case and the data you need returned: | ||
|
||
- TODO | ||
|
||
### Profile Data | ||
|
||
Data returned from the provider is dependent on how your TODO OAuth2 application is configured. The example below assumes that the TODO OAuth2 application is configured to return the user's email, first name, and last name. Fields returned by the provider can change based on the scopes requested and the user's TODO account settings. | ||
|
||
If you aren't sure what data is being returned by the provider, you can log the `profile` object in the `createStrategy` function to see what data is available as seen in the following example. | ||
|
||
<details> | ||
<summary>Configuration Example with Logging</summary> | ||
|
||
```js | ||
// TODO | ||
``` | ||
|
||
</details> | ||
|
||
### Redirect URL/URI | ||
|
||
The redirect URL/URI will be dependent on your provider configuration however in most cases should combine your application's public URL and the provider's callback URL. The example below shows how to combine the public URL with the provider's callback URL. | ||
|
||
```js | ||
callbackURL: | ||
env('PUBLIC_URL', "https://api.example.com") + | ||
strapi.admin.services.passport.getStrategyCallbackURL("TODO"), | ||
``` | ||
|
||
In this example the redirect URL/URI used by the provider will be `https://api.example.com/admin/connect/TODO`. | ||
|
||
This is broken down as follows: | ||
|
||
- `https://api.example.com` is the public URL of your Strapi application | ||
- `/admin/connect` is the general path for SSO callbacks in Strapi | ||
- `/TODO` is the specific provider UID for TODO | ||
|
||
## Strapi Configuration | ||
|
||
Using: // TODO | ||
|
||
### Install the Provider Package | ||
|
||
<Tabs groupId="yarn-npm"> | ||
|
||
<TabItem value="yarn" label="yarn"> | ||
|
||
```sh | ||
// TODO | ||
``` | ||
|
||
</TabItem> | ||
|
||
<TabItem value="npm" label="npm"> | ||
|
||
```sh | ||
// TODO | ||
``` | ||
|
||
</TabItem> | ||
|
||
</Tabs> | ||
|
||
### Adding the Provider to Strapi | ||
|
||
<Tabs groupId="js-ts"> | ||
|
||
<TabItem value="javascript" label="JavaScript"> | ||
|
||
```js title="./config/admin.js" | ||
|
||
// TODO | ||
``` | ||
|
||
</TabItem> | ||
|
||
<TabItem value="typescript" label="TypeScript"> | ||
|
||
```ts title="./config/admin.ts" | ||
|
||
// TODO | ||
``` | ||
|
||
</TabItem> | ||
|
||
</Tabs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,99 @@ | ||
--- | ||
title: Discord SSO provider | ||
description: Learn how to configure the SSO provider to sign in and sign up into your Strapi application through Discord. | ||
title: Discord - Admin SSO Provider | ||
description: Steps to configure Discord as a Strapi Admin SSO Provider | ||
displayed_sidebar: cmsSidebar | ||
tags: | ||
- SSO | ||
- providers | ||
- discord | ||
- additional configuration | ||
- admin panel | ||
- configuration | ||
- Enterprise feature | ||
- SSO | ||
--- | ||
|
||
# Discord provider SSO configuration | ||
|
||
The present page explains how to setup the Discord provider for the [Single Sign-On (SSO) feature](/user-docs/features/sso). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep this intro. It includes a link back to the feature page |
||
import SSOServerConfig from '/docs/snippets/configuration-sso-server.md' | ||
import SSOAdminConfig from '/docs/snippets/configuration-sso-admin.md' | ||
import SSOMiddlewaresConfig from '/docs/snippets/configuration-sso-middlewares.md' | ||
|
||
:::prerequisites | ||
You have read the [How to configure SSO guide](/dev-docs/configurations/guides/configure-sso). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep the first prereq. It includes a link back to the general guide 🙏 |
||
|
||
- [Properly configure Strapi for SSO](#required-configuration-before-setting-up-sso) | ||
- Create your Discord OAuth2 app by following the steps in the [Discord Developer Console](https://discord.com/developers/docs/topics/oauth2). | ||
- Gather the required information to set as environment variables in your Strapi project: | ||
- DISCORD_CLIENT_ID | ||
- DISCORD_SECRET | ||
|
||
::: | ||
|
||
## Installation | ||
## Required configuration before setting up SSO | ||
|
||
### Server Configuration | ||
|
||
<SSOServerConfig /> | ||
|
||
### Admin Configuration | ||
|
||
<SSOAdminConfig /> | ||
|
||
### Middlewares Configuration | ||
|
||
<SSOMiddlewaresConfig /> | ||
|
||
## Provider Specific Notes | ||
|
||
### Scopes | ||
|
||
The Discord OAuth2 provider requires the following scopes, however additional scopes can be added as needed depending on your use case and the data you need returned: | ||
|
||
- [`identify`](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes) | ||
- [`email`](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes) | ||
|
||
### Profile Data | ||
|
||
Data returned from the provider is dependent on how your Discord OAuth2 application is configured. The example below assumes that the Discord OAuth2 application is configured to return the user's email and username. Fields returned by the provider can change based on the scopes requested and the user's Discord account settings. | ||
|
||
If you aren't sure what data is being returned by the provider, you can log the `profile` object in the `createStrategy` function to see what data is available as seen in the following example. | ||
|
||
<details> | ||
<summary>Configuration Example with Logging</summary> | ||
|
||
Install [passport-discord](https://github.com/nicholastay/passport-discord#readme): | ||
```js | ||
(accessToken, refreshToken, profile, done) => { | ||
// See what is returned by the provider | ||
console.log(profile); | ||
|
||
done(null, { | ||
email: profile.email, | ||
username: `${profile.username}`, | ||
}); | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
### Redirect URL/URI | ||
|
||
The redirect URL/URI will be dependent on your provider configuration however in most cases should combine your application's public URL and the provider's callback URL. The example below shows how to combine the public URL with the provider's callback URL. | ||
|
||
```js | ||
callbackURL: | ||
env('PUBLIC_URL', "https://api.example.com") + | ||
strapi.admin.services.passport.getStrategyCallbackURL("discord"), | ||
``` | ||
|
||
In this example the redirect URL/URI used by the provider will be `https://api.example.com/admin/connect/discord`. | ||
|
||
This is broken down as follows: | ||
|
||
- `https://api.example.com` is the public URL of your Strapi application | ||
- `/admin/connect` is the general path for SSO callbacks in Strapi | ||
- `/discord` is the specific provider UID for Discord | ||
|
||
## Strapi Configuration | ||
|
||
Using: [passport-discord](https://github.com/nicholastay/passport-discord) | ||
|
||
### Install the Provider Package | ||
|
||
<Tabs groupId="yarn-npm"> | ||
|
||
|
@@ -40,15 +115,13 @@ npm install --save passport-discord | |
|
||
</Tabs> | ||
|
||
## Configuration example | ||
|
||
The Discord SSO provider is configured in the `auth.providers` array of [the `config/admin` file](/dev-docs/configurations/admin-panel): | ||
### Adding the Provider to Strapi | ||
|
||
<Tabs groupId="js-ts"> | ||
|
||
<TabItem value="javascript" label="JavaScript"> | ||
|
||
```jsx title="/config/admin.js" | ||
```js title="./config/admin.js" | ||
|
||
const DiscordStrategy = require("passport-discord"); | ||
|
||
|
@@ -66,6 +139,7 @@ module.exports = ({ env }) => ({ | |
clientID: env("DISCORD_CLIENT_ID"), | ||
clientSecret: env("DISCORD_SECRET"), | ||
callbackURL: | ||
env('PUBLIC_URL') + | ||
strapi.admin.services.passport.getStrategyCallbackURL( | ||
"discord" | ||
), | ||
|
@@ -74,7 +148,7 @@ module.exports = ({ env }) => ({ | |
(accessToken, refreshToken, profile, done) => { | ||
done(null, { | ||
email: profile.email, | ||
username: `${profile.username}#${profile.discriminator}`, | ||
username: `${profile.username}`, | ||
}); | ||
} | ||
), | ||
|
@@ -88,7 +162,7 @@ module.exports = ({ env }) => ({ | |
|
||
<TabItem value="typescript" label="TypeScript"> | ||
|
||
```ts title="/config/admin.ts" | ||
```ts title="./config/admin.ts" | ||
|
||
import { Strategy as DiscordStrategy } from "passport-discord"; | ||
|
||
|
@@ -107,6 +181,7 @@ export default ({ env }) => ({ | |
clientID: env("DISCORD_CLIENT_ID"), | ||
clientSecret: env("DISCORD_SECRET"), | ||
callbackURL: | ||
env('PUBLIC_URL') + | ||
strapi.admin.services.passport.getStrategyCallbackURL( | ||
"discord" | ||
), | ||
|
@@ -115,7 +190,7 @@ export default ({ env }) => ({ | |
(accessToken, refreshToken, profile, done) => { | ||
done(null, { | ||
email: profile.email, | ||
username: `${profile.username}#${profile.discriminator}`, | ||
username: `${profile.username}`, | ||
}); | ||
} | ||
), | ||
|
@@ -128,5 +203,3 @@ export default ({ env }) => ({ | |
</TabItem> | ||
|
||
</Tabs> | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the original title in files