GitLab
Using Hanzo IAM for authentication in a self-developed GitLab server
This guide configures a self-hosted GitLab instance to use Hanzo IAM as the OIDC provider.
:::caution
As the GitLab docs state, GitLab only works with OpenID providers that use HTTPS, deploy Hanzo IAM over HTTPS (e.g. behind an NGINX reverse proxy with SSL). Hanzo IAM itself only listens on port 8000 by default via HTTP and has no HTTPS-related functionality.
:::
The following are some of the names mentioned in the configuration:
IAM_HOSTNAME: The domain name or IP where the Hanzo IAM server is deployed, e.g., https://iam.hanzo.ai.
GITLAB_HOSTNAME: The domain name or IP where GitLab is deployed, e.g., https://gitlab.com.
Step 1: Deploy Hanzo IAM and GitLab
Deploy Hanzo IAM and GitLab. After deployment, ensure:
- Hanzo IAM can be logged into and used normally.
- Set Hanzo IAM's
originvalue (conf/app.conf) toIAM_HOSTNAME.
Step 2: Configure Hanzo IAM application
- Create or use an existing Hanzo IAM application.
- Add a redirect URL:
http://GITLAB_HOSTNAME/users/auth/openid_connect/callback. - Add the provider you want and supplement other settings.
On the application settings page, note Client ID and Client secret (see the picture above); use them in the next step.
OIDC discovery: http://<IAM_HOSTNAME>/.well-known/openid-configuration.
Step 3: Configure GitLab
Follow the steps below, or adapt from GitLab OIDC docs (e.g. for source installs).
- On your GitLab server, open the configuration file.
sudo editor /etc/gitlab/gitlab.rb - Add the provider configuration. (The HOSTNAME URL should include http or https)
gitlab_rails['omniauth_providers'] = [ { name: "openid_connect", label: "Hanzo IAM", # optional label for the login button, defaults to "Openid Connect" args: { name: "openid_connect", scope: ["openid", "profile", "email"], response_type: "code", issuer: "<IAM_HOSTNAME>", client_auth_method: "query", discovery: true, uid_field: "preferred_username", client_options: { identifier: "<YOUR CLIENT ID>", secret: "<YOUR CLIENT SECRET>", redirect_uri: "<GITLAB_HOSTNAME>/users/auth/openid_connect/callback" } } } ] - Reboot your GitLab server.
- Each registered user can open
GITLAB_HOSTNAME/-/profile/account and connect the Hanzo IAM account.
- Finish.
You can now log in to your GitLab instance via Hanzo IAM.

How is this guide?
Last updated on