This version of the SonarQube documentation is no longer maintained. It relates to a version of SonarQube that is not active.

See latest version
Start Free
10.2 | Instance administration | Authentication and provisioning | GitHub

GitHub

On this page

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 integration.

Creating a dedicated app for authentication

First, you'll need to create a GitHub App. If you're already using a GitHub App for pull request decoration (see GitHub integration), 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. 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 at Administration > General > Server base URL.
    • Callback URL: The public URL of your SonarQube server. For example, https://sonarqube.mycompany.com.
    • Webhooks: Deactivate the feature.
  • Permissions & events tab: 
PermissionAccessComment
Organization Permissions > MembersRead-only
Account permissions > Email addressesRead-only
Organization permissions > Administration
Read-only

Only for automatic provisioning.

After saving, the App owner must validate the permission change.

Repository permissions > Administration
Read-only

Only for automatic provisioning.

After saving, the App owner must validate the permission change.

  • 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 (see below).

Setting your authentication settings in SonarQube

Connecting your GitHub App to SonarQube

Step 1: In SonarQube, 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. 

Step 5: Click Save configuration.

Selecting the user and group provisioning method

Once you've created your GitHub 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: 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 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 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. 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 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 using their GitHub accounts by clicking the Login with GitHub button.

About user permission synchronization 

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.

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

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

Permission mapping

The following permission mapping applies.

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


BrowseSee Source CodeAdminister Issues /  Administer Security HotspotsAdministerScan
Read (pull)
Checkmark icon
Checkmark icon
cross icon
cross icon
cross icon
Triage (pull, triage)
Checkmark icon
Checkmark icon
cross icon
cross icon
cross icon
Write (pull, triage, push)
Checkmark icon
Checkmark icon
Checkmark icon
cross icon
Checkmark icon
Maintain (pull, triage, push, maintain)
Checkmark icon
Checkmark icon
Checkmark icon
cross icon
Checkmark icon
Admin (pull, triage, push, maintain, admin)
Checkmark icon
Checkmark icon
Checkmark icon
Checkmark icon
Checkmark icon

Was this page helpful?

© 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