> 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/10.2/instance-administration/authentication/github.md).

# GitHub

In SonarQube Server 10.2, to allow users to log in with GitHub credentials, you must use a GitHub App.

{% hint style="info" %}
**For AI agents:** You're in the SonarQube Server 10.2 documentation. For a list of all 10.2 pages, see the [SonarQube Server 10.2 page index](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2FQfpu1DTKUwWYFCaHqyVO%2Fsonarqube-server-10.2-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 10.2 in the URL with that version. The [latest version](https://docs.sonarsource.com/sonarqube-server/) has no version number in its URL.
{% endhint %}

To allow users to log in with GitHub credentials, you must use a GitHub App. We recommend setting up a dedicated GitHub app for your SonarQube Server integration.

## Creating a dedicated app for authentication <a href="#creating-a-dedicated-app-for-authentication" id="creating-a-dedicated-app-for-authentication"></a>

First, you’ll need to [create a GitHub App](https://docs.github.com/en/apps/creating-github-apps/setting-up-a-github-app/creating-a-github-app). If you’re already using a GitHub App for pull request decoration (see [GitHub integration](/sonarqube-server/10.2/devops-platform-integration/github-integration.md)), you can also use it for user authentication and provisioning.

Configure the following settings in your GitHub App:

* **General** tab:
  * **Homepage URL**: The public URL of your SonarQube Server instance. For example, `https://sonarqube.mycompany.com`. For security reasons, HTTP is not supported, and you must use HTTPS. The public URL is configured in SonarQube Server at **Administration** > **General** > **Server base URL**.
  * **Redirect URI**: The public URL of your SonarQube Server instance. For example, `https://sonarqube.mycompany.com`.
  * **Webhooks**: Deactivate the feature.
* **Permissions & events** tab:

| **Permission**                                       | **Access** | **Comment**                                                                                                    |
| ---------------------------------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------- |
| Organization Permissions > Members                   | Read-only  | <p><br></p>                                                                                                    |
| Account permissions > Email addresses                | Read-only  | <p><br></p>                                                                                                    |
| <p>Organization permissions > Administration<br></p> | Read-only  | <p>Only for automatic provisioning.</p><p>After saving, the App owner must validate the permission change.</p> |
| <p>Repository permissions > Administration<br></p>   | Read-only  | <p>Only for automatic provisioning.</p><p>After saving, the App owner must validate the permission change.</p> |

* **Install App** tab: Click **Install** and validate the installation on each organization you need.
* During App creation, or under the **Advanced** tab, you can make the App *private* or *public*:
  * Make it *private* if you only have one organization.
  * Make it *public* if you have several organizations from where you need users to authenticate and/or be provisioned. Don’t forget to list those as allowed organizations in SonarQube Server (see below).

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

### Connecting your GitHub App to SonarQube Server <a href="#connecting-your-github-app-to-sonarqube" id="connecting-your-github-app-to-sonarqube"></a>

**Step 1**: In SonarQube Server, Navigate to **Administration** > **Configuration** > **General Settings** > **Authentication** > **GitHub** and click **Create configuration**.

**Step 2:** Fill the following fields with information from your GitHub App:

* * **Client ID**
  * **Client Secret**
  * **GitHub App ID**
  * **Private Key**

**Step 3:** Fill the **API url** and **WEB url** fields as recommended by GitHub.\
\*\*\
Step 4:\*\* If your GitHub App is public, it is important that you enter the allowed organizations in the **Organizations** field.

{% hint style="warning" %}
For automatic provisioning, not entering the allowed organizations for a public App can let undesired users authenticate to your SonarQube Server instance, as public GitHub Apps can be installed by anyone.

When using Just-in-Time provisioning, if the allowed organizations are not entered, any user with a GitHub account can log in to the SonarQube Server instance, even if the GitHub App used for authentication is private.
{% endhint %}

**Step 5:** Click **Save** **configuration**.

### Selecting the user and group provisioning method <a href="#selecting-the-user-and-group-provisioning-method" id="selecting-the-user-and-group-provisioning-method"></a>

Once you’ve created your GitHub configuration, you can choose how users and groups are provisioned to SonarQube Server. For an overview of the available provisioning methods, see [Overview](/sonarqube-server/10.2/instance-administration/authentication/overview.md).

**Step 1:** From the **Authentication** > **GitHub** tab, click **Enable configuration**.

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

* * **Just-in-Time user and group provisioning (default)**:
    * Users are provisioned when they authenticate through GitHub for the first time if the option **Allow users to sign up** is enabled.
    * User information and group memberships are updated at each authentication.
    * (Optional) You can synchronize GitHub teams with existing SonarQube Server groups of the same name with the **Synchronize teams as groups** option.
  * **Automatic user, group, and permission provisioning**
    * Users and groups will be synchronized on an hourly basis. The first synchronization happens immediately when you enable the feature.
    * Permissions are synchronized. See below for more information.
    * You can check the status of the synchronization on this configuration page, in the box **Automatic user and group provisioning** box.
    * If needed, you can manually trigger a synchronization by clicking **Synchronize now**.
    * Groups in SonarQube Server are named after the GitHub organizations and teams’ names, ie. *Organization/Team.*
    * The user’s email address is updated only when no address is set in SonarQube Server. Once a new address is set, it is only updated when the user authenticates.

**Step 3:** When you change a setting in your configuration, you can force SonarQube Server to check that it is valid by clicking **Test configuration.**

**Step 4:** Click **Save**.

From the login page, your users can now connect to SonarQube Server using their GitHub accounts by clicking the **Login with GitHub** button.

### About user permission synchronization <a href="#about-user-permission-synchronization" id="about-user-permission-synchronization"></a>

With automatic provisioning, on top of users and groups, project-level group and user permissions are also synchronized from GitHub. Synchronization happens regularly, and it automatically adds or removes permissions from SonarQube Server.

As part of permission synchronization, the visibility of projects is also synchronized. Private GitHub repositories appear as private SonarQube Server projects. Public repositories are mapped to public projects.

For all GitHub-managed users, permissions can no longer be edited on SonarQube Server GitHub projects. Changes of permissions are handled directly in GitHub.

### Permission mapping <a href="#permission-mapping" id="permission-mapping"></a>

The following permission mapping applies.

The first column lists the GitHub permissions. The first row lists the SonarQube Server permissions.

|                                             |                                                                                                                                                                                                                          |                                                                                                                                                                                                                          |                                                                                                                                                                                                                                                   |                                                                                                                                                                                                                                                   |                                                                                                                                                                                                                                                   |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><br></p>                                 | Browse                                                                                                                                                                                                                   | See Source Code                                                                                                                                                                                                          | Administer Issues / Administer Security Hotspots                                                                                                                                                                                                  | Administer                                                                                                                                                                                                                                        | Scan                                                                                                                                                                                                                                              |
| Read (pull)                                 | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![cross icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-57c6853ce4db37e42a9b653d674be8b88792488e%2F081357f27f0fe0c58101a54a2ff5829bc84a0ab5.svg?alt=media) | ![cross icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-57c6853ce4db37e42a9b653d674be8b88792488e%2F081357f27f0fe0c58101a54a2ff5829bc84a0ab5.svg?alt=media) | ![cross icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-57c6853ce4db37e42a9b653d674be8b88792488e%2F081357f27f0fe0c58101a54a2ff5829bc84a0ab5.svg?alt=media) |
| Triage (pull, triage)                       | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![cross icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-57c6853ce4db37e42a9b653d674be8b88792488e%2F081357f27f0fe0c58101a54a2ff5829bc84a0ab5.svg?alt=media) | ![cross icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-57c6853ce4db37e42a9b653d674be8b88792488e%2F081357f27f0fe0c58101a54a2ff5829bc84a0ab5.svg?alt=media) | ![cross icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-57c6853ce4db37e42a9b653d674be8b88792488e%2F081357f27f0fe0c58101a54a2ff5829bc84a0ab5.svg?alt=media) |
| Write (pull, triage, push)                  | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media)                          | ![cross icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-57c6853ce4db37e42a9b653d674be8b88792488e%2F081357f27f0fe0c58101a54a2ff5829bc84a0ab5.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media)                          |
| Maintain (pull, triage, push, maintain)     | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media)                          | ![cross icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-57c6853ce4db37e42a9b653d674be8b88792488e%2F081357f27f0fe0c58101a54a2ff5829bc84a0ab5.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media)                          |
| Admin (pull, triage, push, maintain, admin) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media) | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media)                          | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media)                          | ![Checkmark icon](https://2995682738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9JA8mmyfC7QWzIoP9Meh%2Fuploads%2Fgit-blob-51435de4153f60f46883a8cb66af53e3ff29d70c%2Fgreen-check.svg?alt=media)                          |


---

# 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/10.2/instance-administration/authentication/github.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.
