Configuring GitLab to authenticate with SAML2 enterprise authentication using Ipsilon.
This guide describes how to set up GitLab to authenticate against Ipsilon as a SAML2 SP, with automatic account creation on login.
This guide has been tested with:
but is known to work with older versions.
Generate a new certificate and key to be used for the SAML SP side (for the Common Name of the certificate you can enter anything, as only the key part is used):
openssl genrsa -out server.key 4096
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
hostname
.{crt,key} with the SSL cert and key in (creation of the these is outside the scope of this guide)The auth stanza is as follows:
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = true
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_auto_link_saml_user'] = true
gitlab_rails['omniauth_providers'] = [
{
"name" => "saml",
"args" => {
"label" => "Log in via SAML",
"assertion_consumer_service_url" => "https://gitlab.example.com/users/auth/saml/callback",
"idp_cert" => "< PEM format ipsilon IdP certificate >",
"idp_sso_target_url" => "https://ipsilon.example.com/idp/saml2/SSO/Redirect",
"issuer" => "https://gitlab.example.com",
"name_identifier_format" => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
"certificate" => "< PEM format gitlab SP client cert >",
"private_key" => "< PEM format gitlab SP client key >",
"security" => {
"authn_requests_signed" => "true",
"digest_method" => "XMLSecurity::Document::SHA1",
"signature_method" => "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
}
}
}
]
Change the assertion_consumer_service_url, idp_sso_target_url, issuer, and cert and key entries appropriately. This should end up looking something like:
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = true
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_auto_link_saml_user'] = true
gitlab_rails['omniauth_providers'] = [
{
"name" => "saml",
"args" => {
"label" => "Log in via SAML",
"assertion_consumer_service_url" => "https://gitlab.example.com/users/auth/saml/callback",
"idp_cert" => "-----BEGIN CERTIFICATE-----
MIID...
-----END CERTIFICATE-----",
"idp_sso_target_url" => "https://ipsilon.example.com/idp/saml2/SSO/Redirect",
"issuer" => "https://gitlab.example.com",
"name_identifier_format" => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
"certificate" => "-----BEGIN CERTIFICATE-----
MIIDG...
-----END CERTIFICATE-----",
"private_key" => "-----BEGIN PRIVATE KEY-----
MIIE...
-----END PRIVATE KEY-----",
"security" => {
"authn_requests_signed" => "true",
"digest_method" => "XMLSecurity::Document::SHA1",
"signature_method" => "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
}
}
}
]
After this configuration, there should be a "Sign in with SAML" button on the GitLab login page, but this won't work until the SP configuration is done.
You'll need to the metadata XML file for GitLab to upload to Ipsilon. This can be found at https://gitlab.example.com/users/auth/saml/metadata
In the Ipsilon admin UI, select Identity Providers -> saml2 -> Manage -> Add New. Fill in the following values, at a minimum:
In addition to the above config, the following attribute mappings need to be configured in the SP configuration. These are needed to provide enough information to GitLab to allow new accounts to be created.
Attribute Mappings:
If login or account creation fails, you should receive a 422 error page. The error may be embedded in the url of the page. Also check /var/log/gitlab/gitlab-rails/application.log and /var/log/gitlab/unicorn/unicorn_stdout.log.