Skip navigation
Documentation

Duo Single Sign-On for GitLab self-managed

Last Updated: August 30th, 2023

Add two-factor authentication and flexible security policies to GitLab self-managed SAML 2.0 logins with Duo Single-Sign On. Our cloud-hosted SSO identity provider offers inline user enrollment, self-service device management, and support for a variety of authentication methods — such as passkeys and security keys, Duo Push, or Verified Duo Push — in the Universal Prompt.

Overview

As business applications move from on-premises to cloud hosted solutions, users experience password fatigue due to disparate logons for different applications. Single sign-on (SSO) technologies seek to unify identities across systems and reduce the number of different credentials a user has to remember or input to gain access to resources.

While SSO is convenient for users, it presents new security challenges. If a user's primary password is compromised, attackers may be able to gain access to multiple resources. In addition, as sensitive information makes its way to cloud-hosted services it is even more important to secure access by implementing two-factor authentication and zero-trust policies.

About Duo Single Sign-On

Duo Single Sign-On is our cloud-hosted SSO product which layers Duo's strong authentication and flexible policy engine on top of GitLab self-managed logins. Duo Single Sign-On acts as an identity provider (IdP), authenticating your users using existing on-premises Active Directory (AD) or another SSO IdP. Duo SSO prompts users for two-factor authentication and performs endpoint assessment and verification before permitting access to GitLab self-managed.

Duo Single Sign-On is available in Duo Premier, Duo Advantage, and Duo Essentials plans, which also include the ability to define policies that enforce unique controls for each individual SSO application. For example, you can require that Salesforce users complete two-factor authentication at every login, but only once every seven days when accessing GitLab self-managed. Duo checks the user, device, and network against an application's policy before allowing access to the application.

Configure Single Sign-On

Before configuring GitLab self-managed with Duo SSO using Security Assertion Markup Language (SAML) 2.0 authentication you'll first need to enable Duo Single Sign-On for your Duo account and configure a working authentication source.

Once you have your SSO authentication source working, continue to the next step of creating the GitLab self-managed application in Duo.

Create the GitLab self-managed Application in Duo

  1. Log on to the Duo Admin Panel and navigate to Applications.

  2. Click Protect an Application and locate the entry for GitLab self-managed with a protection type of "2FA with SSO hosted by Duo (Single Sign-On)" in the applications list. Click Protect to the far-right to start configuring GitLab self-managed. See Protecting Applications for more information about protecting applications in Duo and additional application options. You'll need the information on the GitLab self-managed page under Downloads later.

  3. GitLab self-managed uses the Mail attribute, First name attribute, and Last name attribute when authenticating. We've mapped the bridge attributes to Duo Single Sign-On supported authentication source attributes as follows:

    Bridge Attribute Active Directory SAML IdP
    <Email Address> mail Email
    <First Name> givenName FirstName
    <Last Name> sn LastName

    If you are using non-standard attributes for your authentication source, check the Custom attributes box and enter the name of the attributes you wish to use instead.

  4. You can adjust additional settings for your new SAML application at this time — like changing the application's name from the default value, enabling self-service, or assigning a group policy.

  5. Keep the Duo Admin Panel tab open. You will come back to it later.

Duo Universal Prompt

The Duo Universal Prompt provides a simplified and accessible Duo login experience for web-based applications, offering a redesigned visual interface with security and usability enhancements.

Universal Prompt Traditional Prompt
 Duo Push in Universal Prompt  Duo Push in Traditional Prompt

We've already updated the Duo GitLab self-managed application hosted in Duo's service to support the Universal Prompt, so there's no action required on your part to update the application itself. You can activate the Universal Prompt experience for users of new and existing Duo GitLab self-managed applications from the Duo Admin Panel.

Before you activate the Universal Prompt for your application, it's a good idea to read the Universal Prompt Update Guide for more information about the update process and the new login experience for users.

Activate Universal Prompt

Activation of the Universal Prompt is a per-application change. Activating it for one application does not change the login experience for your other Duo applications.

The "Universal Prompt" area of the application details page shows that this application is "Ready to activate", with these activation control options:

  • Show traditional prompt: (Default) Your users experience Duo's traditional prompt via redirect when logging in to this application.
  • Show new Universal Prompt: Your users experience the Universal Prompt via redirect when logging in to this application.

Universal Prompt Info - Application Ready for Universal Prompt

Enable the Universal Prompt experience by selecting Show new Universal Prompt, and then scrolling to the bottom of the page to click Save.

Once you activate the Universal Prompt, the application's Universal Prompt status shows "Activation complete" here and on the Universal Prompt Update Progress report.

Universal Prompt Info - Universal Prompt Activation Complete

Should you ever want to roll back to the traditional prompt, you can return to this setting and change it back to Show traditional prompt. However, this will still deliver the Duo prompt via redirect, not in an iframe.

Universal Update Progress

Click the See Update Progress link to view the Universal Prompt Update Progress report. This report shows the update availability and migration progress for all your Duo applications. You can also activate the new prompt experience for multiple supported applications from the report page instead of visiting the individual details pages for each application.

Configure Gitlab self-managed for SSO

  1. Log into your GitLab self-managed host server.

  2. Open the /etc/gitlab/gitlab.rb file and enter edit mode to edit the file.

  3. Search for OmniAuth Settings in the file.

  4. Copy the coded text below and paste it over the entire omniauth_allow_single_sign_on line, including the #. See the image below for an example.

    gitlab_rails['omniauth_allow_single_sign_on'] = ['saml']

  5. Copy the coded text below and paste it over the entire omniauth_block_auto_created_users line, including the #. See the image below for an example.

    gitlab_rails['omniauth_block_auto_created_users'] = false

  6. Copy the coded text below and paste it over the entire omniauth_auto_link_saml_user line, including the #. See the image below for an example.

    gitlab_rails['omniauth_auto_link_saml_user'] = true

    GitLab self-managed OmniAuth Settings
  7. Return to the Duo Admin Panel. Enter your Gitlab self-managed base URL into the Base URL field.

    Duo GitLab self-managed Base URL Field
  8. In the Duo Admin Panel, scroll to the bottom of the page and click Save.

  9. Return to the /etc/gitlab/gitlab.rb file. Copy the coded text below and paste it over the omniauth_providers lines highlighted in the image below, including the #.

    gitlab_rails['omniauth_providers'] = [
      {
        "name" => "saml",
        "label" => "Provider name"
        "args" => {
          assertion_consumer_service_url: "https://gitlab.example.com/users/auth/saml/callback",
          idp_cert_fingerprint: "43:51:43:a1:b5:fc:8b:b7:0a:3a:a9:b1:0f:66:73:a8",
          idp_sso_target_url: "https://login.example.com/idp",
          issuer: "https://gitlab.example.com",
          name_identifier_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
        }
        }
    ]

    GitLab self-managed OmniAuth Providers
  10. On the label line, replace Provider name with a unique name for your SSO login button. The default name is "Saml".

  11. Return to the Duo Admin Panel. Copy the ACS URL (assertion_consumer_service_url) and paste it over the URL on the assertion_consumer_service_url line in the /etc/gitlab/gitlab.rb file.

    Duo GitLab self-managed ACS URL Field
  12. Return to the Duo Admin Panel. Copy the idp_cert_fingerprint and paste it over the certificate fingerprint on the idp_cert_fingerprint line in the /etc/gitlab/gitlab.rb file.

    Duo GitLab self-managed Certificate Fingerprints
  13. Return to the Duo Admin Panel. Copy the idp_sso_target_url and paste it over the URL on the idp_sso_target_url line in the /etc/gitlab/gitlab.rb file.

    Duo GitLab self-managed Metadata URL
  14. Return to the Duo Admin Panel. Copy the Issuer URL and paste it over the URL on the issuer line in the /etc/gitlab/gitlab.rb file.

    Duo GitLab self-managed Issuer URL
  15. Save the modified /etc/gitlab/gitlab.rb file.

  16. After the file is saved, copy the coded text below and paste it on the last line. Press Enter and wait for the reconfiguration to complete.

    sudo gitlab-ctl reconfigure

Group Mapping

You have the option to map Duo groups to different groups in GitLab self-managed. To map Duo groups, do the following:

  1. Log into your GitLab self-managed host server.

  2. Open the /etc/gitlab/gitlab.rb file and enter edit mode to edit the file.

  3. Search for omniauth_providers in the file.

  4. Under omniauth_providers, create a new line after the label line.

  5. Copy the coded text below and paste it on the new line.

        "groups_attribute" => "Groups",
        "required_groups" => ["Developers", "Freelancers", "Admins", "Auditors"],

  6. Save the modified /etc/gitlab/gitlab.rb file.

  7. After the file is saved, copy the coded text below and paste it on the last line. Press Enter and wait for the reconfiguration to complete.

    sudo gitlab-ctl reconfigure

  8. Return to the Duo Admin Panel. Type your group name into the GitLab Groups field. This must be one of the names required by GitLab ("Developers", "Freelancers", "Admins", or "Auditors").

  9. Select the applicable Duo group from the Duo groups dropdown menu.

    Duo GitLab self-managed Group Mapping Fields
  10. Scroll to the bottom of the page and click Save.

Learn more about GitLab self-managed SSO at GitLab Docs.

Using SSO

You can log on to GitLab self-managed by navigating to your GitLab self-managed SSO page e.g., https://gitlab.yourdomain.com/users/sign_in. Click Duo to be redirected to Duo Single Sign-On to begin authentication.

Active Directory Login

With Active Directory as the Duo SSO authentication source, enter the primary username (email address) on the Duo SSO login page and click or tap Next.

Duo Single Sign-On Login

Enter the AD primary password and click or tap Log in to continue.

Duo Single Sign-On Password

Enable Duo Passwordless to log in to Duo SSO backed by Active Directory authentication without entering a password in the future.

SAML Login

With another SAML identity provider as the Duo SSO authentication source, Duo SSO immediately redirects the login attempt to that SAML IdP for primary authentication. Users do not see the Duo SSO primary login screen.

Duo Authentication

Successful verification of your primary credentials by Active Directory or a SAML IdP redirects back to Duo. Complete Duo two-factor authentication when prompted and then you'll return to GitLab self-managed to complete the login process.

Duo Universal Prompt

* Universal Prompt experience shown.

You can also log into GitLab self-managed using Duo Central, our cloud-hosted portal which allows users to access all of their applications in one spot. Link to GitLab self-managed in Duo Central by adding it as an application tile. Once the tile has been added, log into Duo Central and click the tile for IdP-initiated authentication to GitLab self-managed.

Congratulations! Your GitLab self-managed users now authenticate using Duo Single Sign-On.

See the full user login experience, including expired password reset (available for Active Directory authentication sources) in the Duo End User Guide for SSO.

Enable Remembered Devices

To minimize additional Duo two-factor prompts when switching between GitLab self-managed and your other Duo Single Sign-On SAML applications, be sure to apply a shared "Remembered Devices" policy to your SAML applications.

Troubleshooting

Need some help? Try searching our Knowledge Base articles or Community discussions. For further assistance, contact Support.