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

Refactor SSO Configuration (docs v6) #2363

Draft
wants to merge 1 commit into
base: v6/beta
Choose a base branch
from
Draft
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
130 changes: 130 additions & 0 deletions docusaurus/docs/dev-docs/configurations/sso-providers/auth0.md
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>
111 changes: 92 additions & 19 deletions docusaurus/docs/dev-docs/configurations/sso-providers/discord.md
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
Copy link
Collaborator

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


The present page explains how to setup the Discord provider for the [Single Sign-On (SSO) feature](/user-docs/features/sso).
Copy link
Collaborator

Choose a reason for hiding this comment

The 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).
Copy link
Collaborator

Choose a reason for hiding this comment

The 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">

Expand All @@ -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");

Expand All @@ -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"
),
Expand All @@ -74,7 +148,7 @@ module.exports = ({ env }) => ({
(accessToken, refreshToken, profile, done) => {
done(null, {
email: profile.email,
username: `${profile.username}#${profile.discriminator}`,
username: `${profile.username}`,
});
}
),
Expand All @@ -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";

Expand All @@ -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"
),
Expand All @@ -115,7 +190,7 @@ export default ({ env }) => ({
(accessToken, refreshToken, profile, done) => {
done(null, {
email: profile.email,
username: `${profile.username}#${profile.discriminator}`,
username: `${profile.username}`,
});
}
),
Expand All @@ -128,5 +203,3 @@ export default ({ env }) => ({
</TabItem>

</Tabs>


Loading