Single Sign-On (SSO)
OIDC
OAuth2
SSO
Single Sign-On (SSO) allows users to authenticate with multiple applications using a single set of credentials. This plugin supports OpenID Connect (OIDC) and OAuth2 providers.
SAML support is coming soon. Upvote the feature request on our GitHub
Installation
Migrate the database
Run the migration or generate the schema to add the necessary fields and tables to the database.
See the Schema section to add the fields manually.
Usage
Register an OIDC Provider
To register an OIDC provider, use the createOIDCProvider
endpoint and provide the necessary configuration details for the provider.
A redirect URL will be automatically generated using the provider ID. For instance, if the provider ID is hydra
, the redirect URL would be {baseURL}/api/auth/sso/hydra
. Note that /api/auth
may vary depending on your base path configuration.
Sign In with SSO
To sign in with an SSO provider, you can call signIn.sso
You can sign in using the email with domain matching:
or you can specify the domain:
You can also sign in using the organization slug if a provider is associated with an organization:
To use the server api you can use signInSSO
When a user is authenticated, if the user does not exist, the user will be provisioned using the provisionUser
function. If the organization provisioning is enabled and a provider is associated with an organization, the user will be added to the organization.
Schema
The plugin requires additional fields in the ssoProvider
table to store the provider's configuration.
Field Name | Type | Key | Description |
---|---|---|---|
id | string | A database identifier | |
issuer | string | - | The issuer identifier |
domain | string | - | The domain of the provider |
oidcConfig | string | - | The OIDC configuration |
userId | string | - | The user id |
providerId | string | - | The provider id. Used to identify a provider and to generate a redirect url. |
organizationId | string | - | The organization Id. If provider is linked to an organization. |
Options
Server
provisionUser: A custom function to provision a user when they sign in with an SSO provider.
organizationProvisioning: Options for provisioning users to an organization.
Prop | Type | Default |
---|---|---|
provisionUser | function | - |
organizationProvisioning | object | - |