# Single Sign-On Gold (opens new window)
Single Sign-On on Strapi allows you to configure additional sign-in and sign-up methods for your administration panel.
- A Strapi application running on version 3.5.0 or higher is required.
- To configure SSO on your application, you will need an EE license with a Gold plan (opens new window).
- Make sure the SSO feature is enabled in the admin panel.
- Make sure Strapi is part of the applications you can access with your provider. For example, with Microsoft (Azure) Active Directory, you must first ask someone with the right permissions to add Strapi to the list of allowed applications. Please refer to your provider(s) documentation to learn more about that.
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 (opens new window).
SSO configuration lives in the server configuration of the application, found at
# Accessing the configuration
The providers' configuration should be written within the
auth.providers path of the admin panel configuration.
auth.providers is an array of provider configuration.
# Setting up provider configuration
| ||true||string||The UID of the strategy. It must match the strategy's name|
| ||true||string||The name that will be used on the login page to reference the provider|
| ||false||string||An image URL. If specified, it will replace the displayName on the login page|
| ||true||function||A factory that will build and return a new passport strategy for your provider. Takes the strapi instance as parameter|
uid property is the unique identifier of each strategy and is generally found in the strategy's package. If you are not sure of what it refers to, please contact the maintainer of the strategy.
A passport strategy is usually built by instantiating it using 2 parameters: the configuration object, and the verify function.
# 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.
A specific callback URL can be generated for your provider using the
getStrategyCallbackURL method. This URL also needs to be written on the provider side in order to allow redirection from it.
The format of the callback URL is the following:
strapi.admin.services.passport.getStrategyCallbackURL is a Strapi helper you can use to get a callback URL for a specific provider. It takes a provider name as a parameter and returns a URL.
If needed, this is also where you will put your client ID and secret key for your OAuth2 application.
The verify function is used here as a middleware allowing the user to transform and make extra processing on the data returned from the provider API.
This function always takes a
done method as last parameter which is used to transfer needed data to the Strapi layer of SSO.
Its signature is the following:
void done(error: any, data: object); and it follows the following rules:
erroris not set to
null, then the data sent is ignored, and the controller will throw an error.
- If the SSO's auto-registration feature is disabled, then the
dataobject only need to be composed of an
- If the SSO's auto-registration feature is enabled, then you will need to define (in addition to the
usernameproperty or both
# Adding a provider
Adding a new provider means adding a new way for your administrators to log-in.
To achieve a great flexibility and a large choice of provider, Strapi uses Passport.js (opens new window). Any valid passport strategy that doesn't need additional custom data should therefore work with Strapi.
Strategies such as ldapauth (opens new window) don't work out of the box since they require extra data to be sent from the admin panel. If you want to add an LDAP provider to your application, you will need to write a custom strategy (opens new window). You can also use services such as Okta and Auth0 as bridge services.
# Configuring the provider
To configure a provider, follow the procedure below:
- Make sure to import your strategy in your admin configuration file, either from an installed package or a local file.
- You'll need to add a new item to the
auth.providersarray in your admin panel configuration that will match the format given above
- Restart your application, the provider should appear on your admin login page.
# Configuration providers examples
Configuration example for Google:
Configuration example for Github:
Configuration example for Discord:
Configuration example for Microsoft:
# Keycloak (OpenID Connect)
Configuration example for Keycloak (OpenID Connect):
Configuration example for Okta:
# Performing advanced customization
# Admin panel URL
If the administration panel lives on a host/port different from the Strapi server, the admin panel URL needs to be updated:
url key in the
./config/admin.js configuration file (see admin panel customization documentation).
# Custom Logic
In some scenarios, you will want to write additional logic for your connection workflow such as:
- restricting connection and registration for a specific domain
- triggering actions on connection attempt
- adding analytics
The easiest way to do so is to plug into the verify function of your strategy and write some code.
For example, if you want to allow only people with an official strapi.io email address, you can instantiate your strategy like this:
# Authentication Events
The SSO feature adds a new authentication event:
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 (