GitLab (OIDC)
Self-managed GitLab signs users in through its OpenID Connect OmniAuth provider, with OkYouIn as the provider. An OkYouIn button appears on GitLab’s sign-in page; the password and second factor are entered on OkYouIn’s sign-in page. For OkYouIn’s OIDC provider in general, see OpenID Connect. If you prefer SAML for GitLab, see GitLab (SAML).
Verified on
Section titled “Verified on”| Product | Version | Modes | What was verified |
|---|---|---|---|
| GitLab CE (Omnibus Docker image) | 19.5.3-ce.0 | password + MFA | OmniAuth openid_connect with discovery, PKCE and uid_field: sub; first sign-in with TOTP creates the account (local and Active Directory users); single sign-on from Grafana without a prompt; MFA asked again after the session lifetime; policy deny; sign-out through the after-sign-out path; console revoke; email_verified not needed |
What works
Section titled “What works”- Second factor: TOTP was verified. Push and e-mail MFA were not tested with GitLab.
- Accounts: created at the first sign-in, active at once with the snippet below.
- Not tested: GitLab group sync (a GitLab Premium feature).
Before you start
Section titled “Before you start”- GitLab must be served over HTTPS. OkYouIn accepts only
httpsredirect URIs (httponly for localhost). - OkYouIn’s public URL (Settings ▸ General) must be an
https://address. - Create the application in Access ▸ Applications ▸ Add application ▸ GitLab. The
redirect URI is GitLab’s
external_urlfollowed by/users/auth/openid_connect/callback, for examplehttps://gitlab.example.com/users/auth/openid_connect/callback. Keephttps://gitlab.example.com/users/sign_inin Post-logout redirect URIs. - The Connect tab shows the snippets with your client ID, secret and URLs filled in.
Configure
Section titled “Configure”-
Add the OmniAuth provider to
/etc/gitlab/gitlab.rb:/etc/gitlab/gitlab.rb gitlab_rails['omniauth_allow_single_sign_on'] = ['openid_connect']gitlab_rails['omniauth_block_auto_created_users'] = falsegitlab_rails['omniauth_providers'] = [{name: "openid_connect",label: "OkYouIn",args: {name: "openid_connect",scope: ["openid", "profile", "email"],response_type: "code",issuer: "https://mfa.example.com/oidc",discovery: true,uid_field: "sub",pkce: true,client_options: {identifier: "<CLIENT-ID>",secret: "<CLIENT-SECRET>",redirect_uri: "https://gitlab.example.com/users/auth/openid_connect/callback"}}}] -
Apply it:
sudo gitlab-ctl reconfigure. An OkYouIn button appears on the GitLab sign-in page. -
Set the after-sign-out path (see Sign-out).
-
Allow the application in the policy — see Policy.
Accounts and e-mail
Section titled “Accounts and e-mail”- Account creation. The first SSO sign-in creates the GitLab account: the username from
preferred_username(a directory user’s UPN loses its@domain), the name and the e-mail. Withomniauth_block_auto_created_usersset tofalseit is active at once; GitLab’s default (true) leaves it “pending approval” until an administrator approves it in Admin ▸ Users. - Stable link.
uid_field: "sub"(the OkYouIn user ID) keeps the link when a user is renamed. - E-mail. GitLab takes the e-mail from OkYouIn and marks it confirmed;
email_verifiedis not needed (OkYouIn does not send it). A user without an e-mail in OkYouIn gets atemp-email-for-oauthaddress and is asked to complete the profile. - Linking existing accounts. Linking SSO sign-ins to existing GitLab accounts by e-mail
(
omniauth_auto_link_user) is off by default. Turn it on only if the e-mail addresses in OkYouIn are trusted.
Sign-out
Section titled “Sign-out”GitLab does not call OkYouIn’s end-session URL itself, so by default GitLab’s Sign out leaves the OkYouIn session alive. Set Admin ▸ Settings ▸ General ▸ Sign-in restrictions ▸ After sign-out path to:
https://mfa.example.com/oidc/end_session?client_id=<CLIENT-ID>&post_logout_redirect_uri=https://gitlab.example.com/users/sign_inGitLab’s Sign out then ends the OkYouIn session too. OkYouIn asks “Sign out?” once —
GitLab sends no id_token_hint — and returns to GitLab’s sign-in page.
Revoking a session in Logging ▸ SSO sessions ends the OkYouIn session (the next sign-in asks for the password), but does not end a GitLab session that is already open.
Verify
Section titled “Verify”- In a private window, click OkYouIn on the GitLab sign-in page, enter the password and the code. The account is created (or reused) and you are signed in.
- Open Grafana or another OkYouIn application in the same browser: it signs in without a prompt while the MFA is within the session lifetime.
- Logging ▸ SSO sign-in log shows the MFA round and the allow, with the deciding rules.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause |
|---|---|
| ”Your account is pending approval from your GitLab administrator” | omniauth_block_auto_created_users is still true (GitLab’s default). Approve in Admin ▸ Users, or set it to false. |
| ”Could not authenticate you from OpenIDConnect because “Deny"" | OkYouIn’s policy denied the user; the SSO sign-in log names the rule. |
| Redirect URI not registered | external_url + /users/auth/openid_connect/callback differs from Redirect URIs. |
| Signing out of GitLab does not sign out of OkYouIn | The after-sign-out path is not set. |
| A user is asked to complete the profile | The user has no e-mail in OkYouIn. |