-
Notifications
You must be signed in to change notification settings - Fork 1.3k
OpenID Connect Settings
Aaron Anderson edited this page Nov 2, 2023
·
9 revisions
GitBucket supports the OpenID Connect authentication since 4.21.0.
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.
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
- Issuer:
- 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.
Set up the Azure AD identity provider:
- In the Azure Active Directory admin center, go to
Overview
and copy theTenant ID
for later use below - From the
App registrations
pane, clickNew registration
- Enter the following info:
- Name: (e.g. "GitBucket")
- Supported account types: single tenant, all tenants, or global
- Redirect URI:
http://localhost:8080/signin/oidc
- Click
Register
- From the
Overview
pane, copy theApplication (client) ID
and save it for use below - From the
Certificates & secrets
pane, clickNew client secret
and enter the following info:- Description: (e.g. "WebApp Server")
- Expires: 1 year, 2 years, or never
- Copy the automatically-generated key under the
Value
column for later use below - From the
Token configuration
pane, clickAdd optional claim
, and select the following:- Token type: ID
- Claim: email
- Click the
Add
button
Set up GitBucket:
- Sign in as an administrator
- Open
System settings
and click theAuthentication
tab - Check
OpenID Connect
and enter the following:- Issuer:
https://sts.windows.net/[tenant-id-from-the-first-step]/
(make sure to include the trailing slash) - Client ID: use the client ID copied from step 5
- Client secret: use the generated key from step 7
- Expected signature algorithm: RS256
- Issuer:
- Sign out.
- Sign in with OpenID Connect.
Setup your Keycloak:
- Create a new Client on your Keycloak.
- Client ID:
gitbucket
- Client Protocol: OpenID Connect
- Valid redirect URIs:
http://localhost:8080/signin/oidc
- Valid post logout redirect URIs:
http://localhost:8080
- Client authentication: On
- Client ID:
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/realms/YOUR_REALM
(replacekeycloak.example.com
with your host name andYOUR_REALM
with your realm) - Client ID:
gitbucket
- Client secret: See Credetials tab in Keycloak
- Expected signature algorithm: RS256
- Issuer:
- Sign out.
- Sign in with OpenID Connect.
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@
).
- If the
- 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
andsub
claim). - Sign in as the user.
To migrate existing users from password login to federated login, entries must be added to the ACCOUNT_FEDERATION table that map the issuer and subject (sub) to the account in the ACCOUNT table.