Start Free
10.6 | Instance administration | Authentication and provisioning | GitLab

Was this page helpful?


On this page

To allow users to log in with GitLab credentials, you'll need to connect SonarQube to a GitLab OAuth 2 application. This will also allow you to configure users and groups.

Creating a GitLab application for authentication and provisioning

  1. First, you'll need a GitLab OAuth 2 application. We recommend creating a dedicated application for authentication and provisioning, but if you're already using one for pull request decoration (see GitLab integration), you can also use it for authentication and provisioning. See the GitLab documentation for information on how to create the application.
  2. Specify the following settings in your GitLab application:
    • Name: Your app's name, such as SonarQube.
    • Redirect URI: <Your SonarQube URL>/oauth2/callback/gitlab. For example,
    • Scopes: Select api if you plan to enable group synchronization. Select read_user if you only plan to delegate authentication.
  3. Save your application. 

GitLab then takes you to the application's page, where you can find your Application ID and Secret.

Connecting your GitLab application to SonarQube

  1.  In SonarQube, Navigate to Administration > Configuration > General Settings > Authentication > GitLab and click Create configuration.
  2. Fill the following fields with information from your GitLab application: 
    • Application ID
    • GitLab URL: We recommend using You can also use your own GitLab server URL.
    • Secret
  3. Synchronize user groups: For each GitLab group they belong to, users will be assigned to a group with the same name (if it exists) in SonarQube.
    On SonarQube, groups you want to synchronize must be named according to their GitLab URL:
  4. Click Save configuration.

Choosing the provisioning method

Once you've created your GitLab configuration, you can choose how users and groups are provisioned to SonarQube. For an overview of the available provisioning methods, see Authentication and provisioning.

Step 1: In SonarQube, go to Authentication > GitLab and click Enable configuration.

Step 2: Select a provisioning method. The available options are: 

  • Just-in-Time user and group provisioning (default):
    • The Allow users to sign up option allows new users to authenticate. When enabled, users are provisioned when they authenticate through Gitlab for the first time. When disabled, only existing users can authenticate to the server.
    • Use Allowed groups to restrict users allowed on SonarQube to certain GitLab groups. Only members of these groups (and sub-groups) will be allowed to authenticate. Enter the group slug as it appears in the GitLab URL, for instance, if the group URL is, then enter my-gitlab-group.
    • User information and group memberships are updated at each authentication.
  • Automatic user and group provisioning (starting in Developer Edition):
    • Users and groups are synchronized on an hourly basis. The first synchronization happens immediately when you enable the feature.
    • The following information is required:
      • Provisioning token: GitLab token used for user provisioning. You can use either a group or a personal access token, as long as it has visibility on the desired groups. The token's scope must include read_api.
      • Allowed groups: ​​Only members of these groups (and sub-groups) will be provisioned. Enter the group slug as it appears in the GitLab URL, for example, "my-gitlab-group". Provisioning can only start from a group that has no parent, you can't define a sub-group here.
    • You can check the status of the synchronization on this configuration page, in the Automatic user and group provisioning box.
    • If needed, you can manually trigger a synchronization by clicking Synchronize now.
    • Groups in SonarQube are named after the GitLab groups' names, for example, GroupA/GroupB.
    • The user's email address is only set when the user authenticates. Automatic synchronization won't set or update emails.

Step 3: Click Save.

From the login page, your users can now log in to SonarQube using their GitLab accounts by clicking the Log in with GitLab button.

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARLINT, SONARQUBE, SONARCLOUD, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License