GitLab SSO with SAML
Configure GitLab single sign-on (SSO) in IDaaS by using the SAML protocol.
Overview
GitLab is an open-source repository management project that uses Git for code management and provides a web-based service.
GitLab supports multiple SSO protocols. This topic describes how to integrate GitLab by using the SAML protocol. For more information, see the GitLab SAML documentation.
Procedure
Step 1: Configure the IDaaS application
As an administrator, go to and search for the GitLab SAML application. Confirm the application name to complete the setup.
After the application is created, you are automatically redirected to the SSO configuration page.
Configure SSO
Enter the GitLab service address. Make sure that the address does not end with a forward slash (/).
Leave the other options at their default values and click Save to complete the SSO configuration.
Application account: By default, the IDaaS username is used as the application logon identifier. GitLab can create accounts automatically. During SSO, if the specified account does not exist in GitLab, GitLab creates the account. For more flexible configurations, see the application account section of General SSO configuration instructions. Authorization scope: By default, the application is available to all users. To specify the IDaaS accounts that can access the application, see the application account section of General SSO configuration instructions.
The lower part of the configuration page lists the parameters that are required to configure GitLab. After you save the SSO configuration, go to the Application configuration information page to obtain the following parameters: the IdP Metadata URL (copy or download), the IdP Entity ID, the IdP Sign-in URL, the SLO URL (not currently supported), and the Certificate (copy the certificate content or download the .cer file). These parameters are required for the subsequent GitLab configuration.
Step 2: Configure GitLab
As described in the official GitLab documentation, edit the GitLab configuration file in your deployment environment.
# If you installed GitLab by using Omnibus, run this command:
sudo editor /etc/gitlab/gitlab.rb
#If you installed GitLab from source, run these commands:
cd /home/git/gitlab
sudo -u git -H editor config/gitlab.yml
Add the following information to the configuration file (the parameters are provided for an Omnibus installation; a source installation uses the same parameters in a different format. For more information, see the official GitLab documentation):
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['saml']
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_auto_link_saml_user'] = true
gitlab_rails['omniauth_providers']=[
{
name: 'saml',
args: {
name: 'saml',
assertion_consumer_service_url:'http://gitlab.example.com/users/auth/saml/callback',
issuer:'http://gitlab.example.com/users/auth/saml',
idp_cert_fingerprint:'23:f8:77:03:fc:69:4c:da:ac:7e:4a:42:5a:87:5a:b3:ad:a8:d9:df',
idp_sso_target_url:'https://example.aliyunidaas.com/login/app/app_mivpoqqmz7zrslxcmlyxa25me4/saml2/sso',
name_identifier_format:'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
attribute_statements: {
nickname: ['username'],
},
},
label:'EIAM2.0'
}
]
Most of the preceding parameters do not need to be changed. You need to modify only the following parameters:
|
Parameter |
Description |
Example |
|
args.assertion_consumer_service_url |
The assertion consumer service URL of GitLab. This is usually the GitLab service address followed by /users/auth/saml/callback. |
http://gitlab.example.com/users/auth/saml/c****ack |
|
args.issuer |
The identity of GitLab. This is usually the GitLab service address followed by /users/auth/saml. |
http://gitlab.****ple.com/users/auth/saml |
|
args.idp_sso_target_url |
The IdP Sign-in URL, which is obtained from IDaaS. |
https://example.aliyunidaas.com/login/app/app_mi****qmz7zrslxcmlyxa25me4/saml2/sso |
|
args.idp_cert_fingerprint |
The fingerprint of the IdP public key certificate. Download the certificate and check the certificate properties to get the SHA1 fingerprint. The fingerprint may not be separated by colons (:). In this case, add the colons manually. |
23:f8:77:03:fc:69:4c:da:ac:7e:4a:42:5a:87:5a:b3:ad:a8:d**** |
After you complete the configuration, run a command to restart GitLab.
# If you installed GitLab by using Omnibus, run these commands to reload the configuration file and restart the service:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
# If you installed GitLab from source, run these commands:
# On systems that run systemd
sudo systemctl restart gitlab.target
# On systems that run SysV init
sudo service gitlab restart
After the restart, the Log on with an Alibaba Cloud IDaaS account option appears at the bottom of the GitLab logon page.
The configuration is complete.
Step 3: Test SSO
You can now test GitLab SSO.
The GitLab integration described in this topic uses the SAML protocol and supports both IdP-initiated SSO (initiated from Alibaba Cloud IDaaS) and SP-initiated SSO (initiated from GitLab).
IdP-initiated SSO
Log on to the IDaaS portal with an IDaaS account that is authorized to use GitLab, and then click the GitLab icon on the page to initiate SSO.
After the configuration is complete, the My Applications page of the IDaaS application portal shows the GitLab application card that you added. If the card indicates that no application account is configured, configure an application account for the current user first. Then click the application to initiate IdP-initiated single sign-on.
SP-initiated SSO
Open the GitLab logon page in an incognito browser window and click Alibaba Cloud IDaaS. You are redirected to IDaaS for logon. If you are not logged on to IDaaS, IDaaS guides you through the logon process.
After IDaaS verifies your identity, you are logged on to GitLab.