-
-
Notifications
You must be signed in to change notification settings - Fork 977
Add section about setting up OIDC as external authentication provider #1301
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,3 +12,65 @@ This page is under construction. | |||||||||||||||||
| For the moment, please refer to [this pull request](https://github.com/mastodon/mastodon/pull/16221) | ||||||||||||||||||
| {{< /hint >}} | ||||||||||||||||||
|
|
||||||||||||||||||
| # OmniAuth | ||||||||||||||||||
| Mastodon supports the CAS, SAML and OpenID Connect protocols for external authentication. | ||||||||||||||||||
| These can either be configured in addition to native logins on Mastodon or as the sole | ||||||||||||||||||
| identity provider using `OMNIAUTH_ONLY=true`. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## OpenID Connect | ||||||||||||||||||
| OpenID is configured using these environment variables. | ||||||||||||||||||
| ``` | ||||||||||||||||||
| OIDC_ENABLED= | ||||||||||||||||||
| OIDC_DISPLAY_NAME= | ||||||||||||||||||
| OIDC_ISSUER= | ||||||||||||||||||
| OIDC_DISCOVERY= | ||||||||||||||||||
| OIDC_CLIENT_AUTH_METHOD | ||||||||||||||||||
| OIDC_SCOPE= | ||||||||||||||||||
| OIDC_RESPONSE_TYPE= | ||||||||||||||||||
| OIDC_RESPONSE_MODE= | ||||||||||||||||||
| OIDC_DISPLAY= | ||||||||||||||||||
| OIDC_PROMPT= | ||||||||||||||||||
|
Contributor
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. In mastodon/mastodon#31131 I'm adding support for PKCE with OIDC providers, so if that's merged before this documentation change lands, we should make sure that it is documented here too.
|
||||||||||||||||||
| OIDC_SEND_NONCE= | ||||||||||||||||||
| OIDC_SEND_SCOPE_TO_TOKEN_ENDPOINT= | ||||||||||||||||||
| OIDC_IDP_LOGOUT_REDIRECT_URI= | ||||||||||||||||||
|
Contributor
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. This can be used in combination with |
||||||||||||||||||
| OIDC_UID_FIELD= | ||||||||||||||||||
| OIDC_CLIENT_ID= | ||||||||||||||||||
| OIDC_REDIRECT_URI= | ||||||||||||||||||
| OIDC_HTTP_SCHEME= | ||||||||||||||||||
| OIDC_HOST= | ||||||||||||||||||
| OIDC_PORT= | ||||||||||||||||||
| OIDC_AUTH_ENDPOINT= | ||||||||||||||||||
| OIDC_TOKEN_ENDPOINT= | ||||||||||||||||||
| OIDC_USER_INFO_ENDPOINT= | ||||||||||||||||||
| OIDC_JWKS_URI= | ||||||||||||||||||
| OIDC_END_SESSION_ENDPOINT= | ||||||||||||||||||
| OIDC_SECURITY_ASSUME_EMAIL_IS_VERIFIED= | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| Many of these variables can be omitted if the identity provider supports discovery using `OIDC_DISCOVERY=true`. | ||||||||||||||||||
|
|
||||||||||||||||||
| With that variable set, the environment variables that have to be configured are: | ||||||||||||||||||
| ``` | ||||||||||||||||||
| OIDC_ENABLED=true | ||||||||||||||||||
| OIDC_ISSUER=<URI to IdP> # For Keycloak, this is the realm's URI. | ||||||||||||||||||
| OIDC_DISCOVERY=true | ||||||||||||||||||
|
Contributor
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. Just a heads up, this can't be used in development with a HTTP scheme issuer, as it crashes because something deep inside omniauth_openid_connect forces HTTPS scheme. So for a HTTP scheme OIDC provider, you need to provide the OIDC_END_SESSION_ENDPOINT allows for doing proper "logout" where you can actually logout of the issuer as well; I'd highly recommend folks setting this, otherwise users are never fully logged out (just the mastodon session is destroyed, the session at the OIDC provider is not destroyed) |
||||||||||||||||||
| OIDC_DISPLAY_NAME=My SSO # this is the name of the login method displayed to the users. Change as you wish. | ||||||||||||||||||
| OIDC_UID_FIELD=preferred_username # Keycloak specific, may vary for your identity provider. | ||||||||||||||||||
| OIDC_CLIENT_ID=mastodon # the client id configured with the IdP.In OIDC, the client is Mastodon. | ||||||||||||||||||
| OIDC_REDIRECT_URI=https://<Mastodon Domain>/auth/auth/openid_connect/callback | ||||||||||||||||||
| OIDC_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true | ||||||||||||||||||
| OIDC_CLIENT_SECRET= # create a confidential client secret with your IdP and provide it here. | ||||||||||||||||||
|
Comment on lines
+59
to
+62
Contributor
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.
Suggested change
Keep client credentials together |
||||||||||||||||||
| OIDC_SCOPE=openid,profile,email # Keycloak specific, maybe adjusted to your identity provider. | ||||||||||||||||||
|
Contributor
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.
Suggested change
These are standard OIDC scopes, and pretty much every OIDC server should have them. |
||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## SAML | ||||||||||||||||||
|
|
||||||||||||||||||
| ## CAS | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Configure SSO as the only authentication method | ||||||||||||||||||
| If you want, you can setup a Mastodon instance and only use external autentication through one of the | ||||||||||||||||||
| methods described above. | ||||||||||||||||||
|
|
||||||||||||||||||
| After setting up an instance with one of the above authentication providers and setting `OMNIAUTH_ONLY=true`, you may want to add `ONE_CLICK_SSO_LOGIN=true` in your environment variables. | ||||||||||||||||||
| This will replace the two `Sign in` and `Sign up` buttons by a single `Login or Register` button, | ||||||||||||||||||
| redirecting people directly to the SSO provider you configured. | ||||||||||||||||||
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.
Also needs docs for
ONE_CLICK_SSO_LOGINcurrently this is hiding under CAS at the bottom of the page, when these two options are usually used together.And there's
SSO_ACCOUNT_SETTINGSandSSO_ACCOUNT_SIGN_UP