How to set the username of mastodon by log in via keycloak

342 views Asked by At

I log into mastodon through keycloak's openid, but mastodon's username is a long meaningless string.I have set the email in keycloak,Although the suffix is ​​different from my domain name.This is my .env.

OIDC_ENABLED=true
OMNIAUTH_ONLY=true
OIDC_DISPLAY_NAME=SSO
OIDC_AUTH_ENDPOINT=https://sso.dora.im/realms/mastodon/protocol/openid-connect/auth
OIDC_ISSUER=https://sso.domain.com/realms/mastodon
OIDC_DISCOVERY=true
OIDC_SCOPE="openid,profile"
OIDC_UID_FIELD=uid
OIDC_CLIENT_ID=mastodon
OIDC_REDIRECT_URI=https://mastodon.domain.com/auth/auth/openid_connect/callback
OIDC_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true
OIDC_CLIENT_SECRET=***

And what does OIDC_UID_FIELD mean?

1

There are 1 answers

0
10935336 On

If you want to set it as the username in keycloak, set OIDC_UID_FIELD to preferred_username, ie OIDC_UID_FIELD=preferred_username.

OIDC_UID_FIELD means from which field of the keycloak response to get the value and use it as the username.

I don't know any other software that can dump Idp output, I learned about it through the dump function of bookstack https://www.bookstackapp.com/docs/admin/oidc-auth/

You will understand immediately once you see the response that sp gets from idp.