triauth for MastodonOIDC
Let your members sign in to your Mastodon server with one approval on their own device, and no Mastodon passwords.
- Sign-in through
- OpenID Connect bridge
- Available in
- Every self-hosted Mastodon, 3.5 and newer
- Set up in
.env.production
About Mastodon
Mastodon is social network software that you run on your own server, in the style of Twitter. People post short messages and follow each other, including people on other Mastodon servers. Organizations run it for public communities or for their own members.
Connect Mastodon to triauth
Mastodon signs people in through the triauth OpenID Connect bridge. Once connected, the sign-in page shows a button with your domain's name under "Or log in with". Members click it, type their username, and approve on their own device. Nobody keeps a Mastodon password, and when someone leaves, removing their identity records at your domain ends their access to the server as well.
How it works
Open oidc.triauth.org and enter your domain. Paste Mastodon's redirect address,
https://social.example.com/auth/auth/openid_connect/callbackwith your own server's address in place ofsocial.example.com, and click Connect app. The bridge gives you a client ID and a client secret.On your server, add the settings below to
.env.productionand restart the Mastodon services. Replaceexample.comwith your domain,social.example.comwith your server's address, and the two placeholders with the client ID and the client secret from the bridge.iniOIDC_ENABLED=true OIDC_DISPLAY_NAME=example.com OIDC_ISSUER=https://oidc.triauth.org/example.com OIDC_DISCOVERY=true OIDC_SCOPE=openid,profile,email OIDC_UID_FIELD=sub OIDC_CLIENT_ID=<client ID from the bridge> OIDC_CLIENT_SECRET=<client secret from the bridge> OIDC_REDIRECT_URI=https://social.example.com/auth/auth/openid_connect/callbackOpen the sign-in page and click the button with your domain's name.
Checkpoint
Mastodon's sign-in page shows a new button with your domain's name under "Or log in with". Choosing it opens a page from the bridge that asks for the username, and the person's authenticator asks them to approve.
Good to know
- Everyone with an identity at your domain gets an account the first time they sign in. Their Mastodon username is the part of their identifier before the
@. To let only one team in, limit the app to a group when you connect it. - Members who already have an account under the same email address are connected to it only when
ALLOW_UNSAFE_AUTH_PROVIDER_REATTACHis on, which Mastodon marks as a security trade-off. OMNIAUTH_ONLY=truehides the password form once everyone is over, andONE_CLICK_SSO_LOGIN=trueturns the two buttons into one.
For the person who connects the app
| Setting | Value |
|---|---|
| Redirect address | https://<your-mastodon>/auth/auth/openid_connect/callback, also set as OIDC_REDIRECT_URI |
| Where in Mastodon | .env.production, then a restart of the web, streaming, and Sidekiq services |
| Issuer | OIDC_ISSUER with OIDC_DISCOVERY=true, from which Mastodon reads the rest. Without discovery, OIDC_AUTH_ENDPOINT, OIDC_TOKEN_ENDPOINT, OIDC_USER_INFO_ENDPOINT, and OIDC_JWKS_URI take the addresses one by one |
| Scopes | OIDC_SCOPE is comma separated |
| Optional | OIDC_USE_PKCE=true adds PKCE, and OIDC_SECURITY_ASSUME_EMAIL_IS_VERIFIED is not needed, since the bridge confirms the email address |
Mastodon's own single sign-on docs page is still a placeholder. The variables above come from Mastodon's configuration source and the pull request that added OpenID Connect, which the configuration reference points to. Mastodon keeps the client secret, so leave This app can't keep a secret unticked when you connect it on the bridge.
Next steps
- Read the OpenID Connect bridge page for what every connected app gets and what the bridge keeps private.
- Read Roll out to your team to give everyone in your organization an identifier at your domain.
- Read Groups to limit the server to one team when you connect it.
- Read Mastodon's configuration reference for the sign-in variables Mastodon documents.
All logos and trademarks belong to their respective owners and do not imply affiliation or endorsement of the organization or product by triauth, nor vice versa. The content provided on this page may include information from third-party sources. We do not assume any responsibility for the completeness, correctness, or applicability of the information. You should independently verify any details before relying on them.