> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-server/9.9/instance-administration/authentication/gitlab.md).

# GitLab

In SonarQube Server 9.9, you can delegate authentication to GitLab using a dedicated GitLab OAuth application.

{% hint style="info" %}
**For AI agents:** You're in the SonarQube Server 9.9 documentation. For a list of all 9.9 pages, see the [SonarQube Server 9.9 page index](https://152261287-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBmptmznn7RpPe5u7vdup%2Fuploads%2F7O6jgZAiehDGe0FMXDaC%2Fsonarqube-server-9.9-llms.txt?alt=media). For the whole site, see the [page index](https://docs.sonarsource.com/llms.txt) or the [full text](https://docs.sonarsource.com/llms-full.txt). For another version, replace 9.9 in the URL with that version. The [latest version](https://docs.sonarsource.com/sonarqube-server/) has no version number in its URL.
{% endhint %}

You can delegate authentication to GitLab using a dedicated GitLab OAuth application.

### Creating a GitLab OAuth app <a href="#creating-a-gitlab-oauth-app" id="creating-a-gitlab-oauth-app"></a>

You can find general instructions for creating a GitLab OAuth app [here](https://docs.gitlab.com/ee/integration/oauth_provider.html).

Specify the following settings in your OAuth app:

* **Name**: Your app’s name, such as SonarQube Server.
* **Redirect URL**: `<Your SonarQube URL>/oauth2/callback/gitlab`. For example, `https://sonarqube.mycompany.com/oauth2/callback/gitlab`.
* **Scopes**: select **api** and **read\_user**

After saving your application, GitLab takes you to the app’s page. Here you find your **Application ID** and **Secret**.

### Setting your authentication settings in SonarQube Server <a href="#setting-your-authentication-settings-in-sonarqube" id="setting-your-authentication-settings-in-sonarqube"></a>

* **Enabled**: Set to true.
* **GitLab URL**: <https://gitlab.com> for cloud version of Gitlab, otherwise your self-hosted GitLab server URL
* **Application ID**: The application ID is found on your GitLab app’s page.
* **Secret**: The secret is found on your GitLab app’s page.
* **Allow users to sign up**: enable to allow new users to authenticate. When disabled, only existing users will be able to authenticate to the server.
* **Allowed groups**: this is to restrict users allowed on SonarQube Server to certain GitLab groups. Only members of these groups (and sub-groups) will be allowed to authenticate. Please enter the group slug as it appears in the GitLab URL, for instance if the group URL is `https://gitlab.com/my-gitlab-group`, then enter `my-gitlab-group`.

{% hint style="warning" %}
If the Allowed groups are not entered, any user with a GitLab account can log in to the SonarQube Server instance (assuming **Allow users to sign up** is set to true).
{% endhint %}

* **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 Server.\
  On SonarQube Server, groups you want to synchronize must be named according to their GitLab URL:
  * `https://gitlab.com/my-gitlab-group` → `my-gitlab-group`
  * `https://gitlab.com/my-gitlab-group/sub-group` → `my-gitlab-group/sub-group`

{% hint style="info" %}
When group synchronization is configured, the delegated authentication source becomes the only place to manage group membership, and the user’s groups are re-fetched with each login. It is not possible to use both manual group memberships and group synchronization (via your ALM integration) for the same user.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sonarsource.com/sonarqube-server/9.9/instance-administration/authentication/gitlab.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
