GitBucket supports the OpenID Connect authentication since 4.21.0.
Prerequisite
Check if your IdP (OpenID Provider) satisfies the followings:
- A client ID and client secret must be given by the IdP.
- The IdP must provide its metadata on
ISSUER_URL/.well-known/openid-configuration.
- The IdP must provide an email address by the
email claim.
- The IdP should provide full name of a user by the
name claim.
- The IdP may provide a username by the
preferred_username claim.
Getting Started
Google Identity Provider (Google Apps)
Setup the Google Identity Provider:
- Open https://console.developers.google.com/apis/credentials
- Create an OAuth client ID.
- Application type: web application
- Authorized redirect URIs:
http://localhost:8080/signin/oidc
- Check the client ID and client secret of the OAuth client.
Setup your GitBucket:
- Sign in as an administrator.
- Open the system settings.
- Turn on OpenID Connect and enter the followings:
- Issuer:
https://accounts.google.com
- Client ID: See Google Identity Provider
- Client secret: See Google Identity Provider
- Expected signature algorithm: RS256
- Sign out.
- Sign in with OpenID Connect.
Note that any Google users can sign in to your GitBucket. Make sure restricted people can access to your GitBucket.
See also https://developers.google.com/identity/protocols/OpenIDConnect.
Azure AD
(This may work. Please feel free to write instructions, anyone)
Keycloak
Setup your Keycloak:
- Create a new Client on your Keycloak.
- Client ID:
gitbucket
- Client Protocol: openid-connect
- Access Type: confidential
- Valid Redirect URIs:
http://localhost:8080/signin/oidc
Setup your GitBucket:
- Sign in as an administrator.
- Open the system settings.
- Turn on OpenID Connect and enter the followings:
- Issuer:
https://keycloak.example.com/auth/realms/YOUR_REALM (replace keycloak.example.com with your host name and YOUR_REALM with your realm)
- Client ID:
gitbucket
- Client secret: See Credetials tab in Keycloak
- Expected signature algorithm: RS256
- Sign out.
- Sign in with OpenID Connect.
How it works
GitBucket does the followings on the OpenID Connect authentication:
- Try to extract the username for the identity from:
- If the
preferred_username claim is given, use it.
- If the
email claim is given, use first part of it (before @).
- Check if the username already exists:
- If the username already exists, raise an error.
- If the username does not exist, create a user.
- Federate the user and the identity (i.e. the pair of
iss and sub claim).
- Sign in as the user.