GitHub

Setting up the GitHub authentication in your SonarQube Community Build instance.

To allow users to log in with GitHub credentials, you’ll need to register SonarQube Community Build as a GitHub App. This will also allow you to configure user, group, and permission provisioning.

Registering SonarQube Community Build as a GitHub App for authentication and provisioning

First, you’ll need to register SonarQube Community Build as a GitHub App. If you’ve already registered SonarQube Community Build as a GitHub App (see Setting up a GitHub App), you can also use it for user authentication and provisioning.

Configure the following settings in your GitHub App:

  • General tab:

    • Homepage URL: The URL of your SonarQube Community Build. For example, https://sonarqube.mycompany.com. For security reasons, HTTP is not supported, and you must use HTTPS. The URL must be configured in SonarQube Server: see Server base URL.

    • Callback URL: The URL of your SonarQube Community Build. For example, https://sonarqube.mycompany.com.

    • Webhooks: Deactivate the feature.

  • Permissions & events tab:

Permission
Access
Comment

Repository permissions > Administration

Read-only

Only for automatic provisioning.

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

Organization permissions > Administration

Read-only

Only for automatic provisioning.

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

Organization Permissions > Members

Read-only

Account permissions > Email addresses

Read-only

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

Connecting your GitHub App to SonarQube Community Build

  1. In SonarQube Community Build, Navigate to Administration > Configuration > General Settings > Authentication > GitHub and click Create configuration.

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

    • Client ID

    • Client Secret

    • GitHub App ID

    • Private Key

  3. Fill the API url and WEB url fields as recommended by GitHub.

  4. If your GitHub App is public, it is important that you enter the allowed organizations in the Organizations field.

  1. Click Save configuration.

Choosing the provisioning method

Once you’ve set up your GitHub configuration, you can choose how users and groups are provisioned to SonarQube Community Build.

  1. In SonarQube Community Build, from the Authentication > GitHub tab, click Enable configuration.

  2. Set up the Just-in-Time user and group provisioning:

    • 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 Community Build groups of the same name with the Synchronize teams as groups option.

    • You must first create and/or verify the groups in Sonarqube Community Build as described in Group synchronization.

  3. When you change a setting in your configuration, you can force SonarQube Community Build to check that it is valid by clicking Test configuration.

  4. Click Save.

From the login page, your users can now connect to SonarQube Community Build using their GitHub accounts by clicking the Log in 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 Community Build.

Enabling the Provision project visibility option allows you to synchronize your projects’ visibility as part of permission synchronization.

  • When enabled, your SonarQube Community Build project’s visibility will match the corresponding GitHub repository’s visibility.

  • When disabled, your SonarQube Community Build project’s visibility will be set to private, regardless of the GitHub repository’s visibility.

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

Permission mapping

SonarQube Community Build applies a default permission mapping that covers most use cases. If you have more advanced needs, you can customize this mapping so that each GitHub base role has exactly the SonarQube Community Build permissions you want. You can also configure permission mapping for GitHub custom roles.

To do this, click on the Edit mapping button in the section related to automatic provisioning.

Here is the default permission mapping. The first column lists the GitHub base role, and the first row lists the SonarQube Community Build permissions.

Here is the default permission mapping. The first column lists the GitHub base role, and the first row lists the SonarQube Server permissions.

Known limitation (GitHub Enterprise only): When a nested team has a custom role that extends the same base role as its parent team’s custom role, the nested team will use its parent’s custom role instead of its own.

Last updated

Was this helpful?