Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Single Sign-On on Strapi allows you to configure additional sign-in and sign-up
It is currently not possible to associate a unique SSO provider to an email address used for a Strapi account, meaning that the access to a Strapi account cannot be restricted to only one SSO provider. For more information and workarounds to solve this issue, [please refer to the dedicated GitHub issue](https://github.com/strapi/strapi/issues/9466#issuecomment-783587648).
:::

SSO configuration lives in the server configuration of the application, found at `/config/server.js`.
SSO configuration lives in the server configuration of the application, found at `./config/admin.js`.

## Accessing the configuration

Expand Down Expand Up @@ -59,9 +59,7 @@ The `uid` property is the unique identifier of each strategy and is generally fo

A passport strategy is usually built by instantiating it using 2 parameters: the configuration object, and the verify function.

<!-- Title below is supposed to be an h7, so one level deeper than "The `createStrategy` Factory. But h7 is not a thing, so using bold instead. 🤷 -->

**Configuration Object**
#### Configuration Object

The configuration object depends on the strategy needs, but often asks for a callback URL to be redirected to once the connection has been made on the provider side.

Expand Down Expand Up @@ -132,7 +130,7 @@ yarn add passport-google-oauth2
::: details Configuration example for Google:

```jsx
// path: ./config/server.js
// path: ./config/admin.js

'use strict';

Expand Down Expand Up @@ -201,7 +199,7 @@ yarn add passport-github2
::: details Configuration example for Github:

```jsx
// path: ./config/server.js
// path: ./config/admin.js

'use strict';

Expand Down Expand Up @@ -265,7 +263,7 @@ yarn add passport-discord
::: details Configuration example for Discord:

```jsx
// path: ./config/server.js
// path: ./config/admin.js

'use strict';

Expand Down Expand Up @@ -329,7 +327,7 @@ yarn add passport-azure-ad-oauth2 jsonwebtoken
::: details Configuration example for Microsoft:

```jsx
// path: ./config/server.js
// path: ./config/admin.js

'use strict';

Expand Down Expand Up @@ -399,7 +397,7 @@ yarn add passport-okta-oauth20
::: details Configuration example for Okta:

```jsx
// path: ./config/server.js
// path: ./config/admin.js

'use strict';

Expand Down Expand Up @@ -462,6 +460,8 @@ The easiest way to do so is to plug into the verify function of your strategy an
For example, if you want to allow only people with an official strapi.io email address, you can instantiate your strategy like this:

```javascript
// path: ./config/admin.js

const strategyInstance = new Strategy(configuration, ({ email, username }, done) => {
// If the email ends with @strapi.io
if (email.endsWith('@strapi.io')) {
Expand All @@ -476,16 +476,14 @@ const strategyInstance = new Strategy(configuration, ({ email, username }, done)

### Authentication Events

The SSO feature adds a new [authentication event](/developer-docs/latest/setup-deployment-guides/configurations/required/server.md#available-options): `onSSOAutoRegistration`.
The SSO feature adds a new [authentication event](/developer-docs/latest/setup-deployment-guides/configurations/required/admin-panel.md#available-options): `onSSOAutoRegistration`.

This event is triggered whenever a user is created using the auto-register feature added by SSO.
It contains the created user (`event.user`), and the provider used to make the registration (`event.provider`).

Example:

`/config/server.js`

```javascript
// path: ./config/admin.js

module.exports = () => ({
// ...
admin: {
Expand Down