Skip to content

Comment on State of OpenID Connect Providersparent

Comments

Based on [1], I believe I can guide you through that:

Given that your keycloak instance is running (and accessible to the user browser) at https://mykeycloak.net, its version is 17 or higher and you are using the realm named _master_.

Given that your gitlab is at https://gitlab.example.com.

At keycloak:

1 - create a new client, name it `gitlab` and set https://gitlab.example.com/users/auth/openid_connect/callbac... as the root url (henceforth CALLBACK_URI)

At keycloak, in the `gitlab` client settings screen, tab settings:

1 - Set `acess type` to `confidential`.

2 - Set `Direct Access Grants Enabled` to off.

3 - Set `Valid Redirect URIs` to `https://gitlab.example.com/users/auth/openid_connect/callbac...`* (that is the CALLBACK_URI followed by a *)

4 - Save it (A previously hidden credentials appear in the settings screen.)

At keycloak, in the `gitlab` client settings screen, tab credentials:

1 - note down your client secret (something like HMPhR89hoxrcotAz9vWjEAlPCWRAx2MP), henceforth CLIENT_SECRET

At your gitlab instance config file, setting gitlab_rails['omniauth_providers']:

1 - Set the content as in [1]

2 - Set args.issuer to https://mykeycloak.net/realms/master

3 - Set args.issuer.client_options.identifier to `gitlab`

4 - Set args.issuer.client_options.secret to CLIENT_SECRET

Hope that helps. If that works for you, please write a public markdown github gist with this tutorial and the title "how to configure gitlab with keycloak?" this will help future google searchers. Be sure to reinclude the question "how to configure gitlab with keycloak?" as a title inside the gist, with the tutorial following, as google favors question and answer style.

[1] = https://docs.gitlab.com/ee/administration/auth/oidc.html#con...

Sadly, this does not work. The logs aren't exactly useful either:

==> /var/log/gitlab/nginx/gitlab_access.log <== 100.107.130.186 - - [23/Dec/2022:16:15:01 +0000] "POST /users/auth/openid_connect HTTP/1.1" 302 107 "https://git-xxx.xxx.de/users/sign_in" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" -

==> /var/log/gitlab/gitlab-rails/application.log <== 2022-12-23T16:15:01.709Z: (openid_connect) Request phase initiated. 2022-12-23T16:15:01.735Z: (openid_connect) Authentication failure! Not Found: OpenIDConnect::Discovery::DiscoveryFailed, Not Found

==> /var/log/gitlab/gitlab-rails/application_json.log <== {"severity":"DEBUG","time":"2022-12-23T16:15:01.709Z","correlation_id":"01GMZW8DH3E10E8NBYKC65MCYR","message":"(openid_connect) Request phase initiated."} {"severity":"ERROR","time":"2022-12-23T16:15:01.735Z","correlation_id":"01GMZW8DH3E10E8NBYKC65MCYR","message":"(openid_connect) Authentication failure! Not Found: OpenIDConnect::Discovery::DiscoveryFailed, Not Found"}

Bring this to keycloak forum and I'll help.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.