Delegating Authentication

SonarQube comes with an onboard user database, as well as the ability to delegate authentication via HTTP Headers, GitHub Authentication, SAML, or LDAP. Each method offers user identity management, group synchronization/mapping and authentication.

Group Mapping

When using group mapping, the following caveats apply regardless of which delegated authentication method is used:

  • membership in synchronized groups will override any membership locally configured in SonarQube at each login
  • membership in a group is synched only if a group with the same name exists in SonarQube
  • membership in the default group sonar-users remains (this is a built-in group) even if the group does not exist in the identity provider

When group mapping is configured, the delegated authentication source becomes the one and only place to manage group membership, and the user's groups are re-fetched with each log in.

HTTP Header Authentication

You can delegate user authentication to third-party systems (proxies/servers) using HTTP Header Authentication.

When this feature is activated, SonarQube expects that the authentication is handled prior any query reaching the server. The tool that handles the authentication should:

  • intercept calls to the SonarQube server
  • take care of the authentication
  • update the HTTP request header with the relevant SonarQube user information
  • re-route the request to SonarQube with the appropriate header information

HTTP Header Authentication flow

All the parameters required to activate and configure this feature are available in SonarQube server configuration file (in $SONARQUBE-HOME/conf/

Using Http header authentication is an easy way integrate your SonarQube deployment with an in-house SSO implementation.

GitHub Authentication

You can delegate authentication to GitHub Enterprise using a dedicated GitHub OAuth application. Alternately, if you're using the pull request decoration provided as part of Developer Edition and above you can harness the GitHub application needed for PR decoration to also provide authentication.

Dedicated GitHub OAuth application

  1. You'll need to first create a GitHub OAuth application. Click here for general instructions:

    1. "Homepage URL" is the public URL to your SonarQube server, for example "Administration -> General -> Server base URL
    2. "Authorization callback URL" is /oauth2/callback, for example ""
  2. In SonarQube navigate to Administration > Configuration > General Settings > GitHub:

    1. Set Enabled to true
    2. Set the Client ID to the value provided by the GitHub developer application
    3. Set the Client Secret to the value provided by the GitHub developer application

On the login form, the new "Log in with GitHub" button allows users to connect with their GitHub Enterprise accounts.

Re-use GitHub PR decoration application

  1. In the GitHub app, in Permission & events > User permissions: Add Read-only access in Emails.
  2. In SonarQube settings, update the Client ID and Client Secret and use values defined in the GitHub app

If you previously used a dedicated GitHub OAuth application for authentication, it can be removed.

SAML Authentication

You can delegate authentication to a SAML 2.0 Identity Provider using SAML Authentication.


  • SAML requests are not signed. Client signature validation should be disabled in the Identity Provider.
  • SAML encrypted responses are not supported. SAML encryption should be disabled in the Identity Provider.

Example: Using Keycloak as a SAML Identity Provider

The following example may be useful if you're using Keycloak as a SAML Identity Provider. If you're not using Keycloak, your settings are likely to be different.

In the Keycloak server, create a new SAML client

Create a new client

  1. "Client ID" is something like "sonarqube"
  2. "Client Protocol" must be set to "saml"
  3. "Client SAML Endpoint" can be left empty

Configure the new client

  1. in Settings

    1. Set"Client Signature Required" to OFF
    2. Set "Valid Redirect URIs" to "/oauth2/callback/*, E.G
  2. in Client Scopes > Default Client Scopes , remove "role_list" from "Assigned Default Client Scopes" (to prevent the error com.onelogin.saml2.exception.ValidationError: Found an Attribute element with duplicated Name during authentication)
  3. In Mappers create a mapper for each user attribute (Note that values provided below for Name, SAML Attribute Name, Role Attribute Name are only example values):

    1. Create a mapper for the login:
    2. Name: Login
    3. Mapper Type: User Property
    4. Property: Username (Note that the login should not contain any special characters other than .-_@ to meet SonarQube restrictions.)
    5. SAML Attribute Name: login
    6. Create a mapper for the name:
    7. Name: Name
    8. Mapper Type: User Property
    9. User Attribute: Username (It can also be another attribute you would previously have specified for the users)
    10. SAML Attribute Name: name
    11. (Optional) Create a mapper for the email:
    12. Name: Email
    13. Mapper Type: User Property
    14. Property: Email
    15. SAML Attribute Name: email
    16. (Optional) Create a mapper for the groups (If you rely on a list of roles defined in "Roles" of the Realm (not in "Roles" of the client)):
    17. Name: Groups
    18. Mapper Type: Role list
    19. Role Attribute Name: groups
    20. Single Role Attribute: ON
    21. If you rely on a list of groups defined in "Groups":
    22. Name: Groups
    23. Mapper Type: Group list
    24. Role Attribute Name: groups
    25. Single Role Attribute: ON
    26. Full Group Path: OFF

Download the XML configuration file in Installations > Format Option > SAML Metadata IDPSSODescriptor

In SonarQube, Configure SAML authentication

Go to Administration > Configuration > General Settings > SAML > Authentication

  • Enabled should be set to true
  • Application ID is the value of the "Client ID" you set in Keycloak (for example "sonarqube")
  • Provider ID is the value of the "EntityDescriptor" > "entityID" attribute in the XML configuration file (for example "http://keycloak:8080/auth/realms/sonarqube" where sonarqube is the name of the realm)
  • SAML login url is the value of "SingleSignOnService" > "Location" attribute in the XML configuration file (for example "http://keycloak:8080/auth/realms/sonarqube/protocol/saml")
  • Provider certificate is the value of "dsig:X509Certificate" node in the XML configuration file
  • SAML user login attribute is the value set in the login mapper in "SAML Attribute Name"
  • SAML user name attribute is the value set in the name mapper in "SAML Attribute Name"
  • (Optional) SAML user email attribute is the value set in the email mapper in "SAML Attribute Name"
  • (Optional) SAML group attribute is the value set in the groups mapper in "Role/Group Attribute Name"

In the login form, the new button "Log in with SAML" allows users to connect with their SAML account.

LDAP Authentication

You can configure SonarQube authentication and authorization to an LDAP server (including LDAP Service of Active Directory) by configuring the correct values in $SONARQUBE-HOME/conf/

The main features are:

  • Password checking against the external authentication engine.
  • Automatic synchronization of usernames and emails.
  • Automatic synchronization of relationships between users and groups (authorization).
  • Ability to authenticate against both the external and the internal authentication systems. There is an automatic fallback on SonarQube internal system if the LDAP server is down.
  • During the first authentication trial, if the user's password is correct, the SonarQube database is automatically populated with the new user. Each time a user logs into SonarQube, the username, the email and the groups this user belongs to that are refreshed in the SonarQube database. You can choose to have group membership synchronized as well, but this is not the default.
  Apache DS OpenLDAP Open DS Active Directory

= successfully tested


  1. Configure the LDAP plugin by editing $SONARQUBE-HOME/conf/ (see table below)
  2. Restart the SonarQube server and check the log file for:

    INFO org.sonar.INFO Security realm: LDAP ...
    INFO o.s.p.l.LdapContextFactory Test LDAP connection: OK
  3. Log into SonarQube
  4. On logout users will be presented a login page (/sessions/login), where they can choose to login as technical user or a domain user by passing appropriate credentials

From SonarScanners, we recommend using local technical users for authentication against SonarQube Server.

General Configuration

Property Description Default value Required Example Set this to LDAP authenticate first against the external sytem. If the external system is not reachable or if the user is not defined in the external system, authentication will be performed against SonarQube's internal database. none Yes LDAP (only possible value)
sonar.authenticator.downcase Set to true when connecting to a LDAP server using a case-insensitive setup. false No
ldap.url URL of the LDAP server. If you are using ldaps, you should install the server certificate into the Java truststore. none Yes ldap://localhost:10389
ldap.bindDn The username of an LDAP user to connect (or bind) with. Leave this blank for anonymous access to the LDAP directory. none No cn=sonar,ou=users,o=mycompany
ldap.bindPassword The password of the user to connect with. Leave this blank for anonymous access to the LDAP directory. none No secret
ldap.authentication Possible values: simple, CRAM-MD5, DIGEST-MD5, GSSAPI. See the tutorial on authentication mechanisms simple No
ldap.realm See Digest-MD5 Authentication, CRAM-MD5 Authentication none No
ldap.contextFactoryClass Context factory class. com.sun.jndi.ldap.LdapCtxFactory No
ldap.StartTLS Enable use of StartTLS false No
ldap.followReferrals Follow referrals or not. See Referrals in the JNDI true

User Mapping

Property Description Default value Required Example for Active Directory
ldap.user.baseDn Distinguished Name (DN) of the root node in LDAP from which to search for users. None Yes cn=users,dc=example,dc=org
ldap.user.request LDAP user request. (&(objectClass=inetOrgPerson)(uid={login})) No (&(objectClass=user)(sAMAccountName={login}))
ldap.user.realNameAttribute Attribute in LDAP defining the user’s real name. cn No
ldap.user.emailAttribute Attribute in LDAP defining the user’s email. mail No

Group Mapping Only groups are supported (not roles). Only static groups are supported (not dynamic groups).

For the delegation of authorization, groups must be first defined in SonarQube. Then, the following properties must be defined to allow SonarQube to automatically synchronize the relationships between users and groups.

Property Description Default value Required Example for Active Directory Distinguished Name (DN) of the root node in LDAP from which to search for groups. none No cn=groups,dc=example,dc=org LDAP group request. (&(objectClass=groupOfUniqueNames)(uniqueMember={dn})) No (&(objectClass=group)(member={dn})) Property used to specifiy the attribute to be used for returning the list of user groups in the compatibility mode. cn No sAMAccountName

Sample Configuration

# LDAP configuration
# General Configuration
# User Configuration
# Group Configuration,dc=sonarsource,dc=com{uid}))

Advanced LDAP Topics

Authentication Methods

  • Anonymous - Used when only read-only access to non-protected entries and attributes is needed when binding to the LDAP server.
  • Simple Simple authentication is not recommended for production deployments not using the ldaps secure protocol since it sends a cleartext password over the network.
  • CRAM-MD5 - The Challenge-Response Authentication Method (CRAM) based on the HMAC-MD5 MAC algorithm (RFC 2195).
  • DIGEST-MD5 - This is an improvement on the CRAM-MD5 authentication method (RFC 2831).
  • GSSAPI - GSS-API is Generic Security Service API (RFC 2744). One of the most popular security services available for GSS-API is the Kerberos v5, used in Microsoft's Windows 2000 platform.

For a full discussion of LDAP authentication approaches, see RFC 2829 and RFC 2251.

Multiple Servers

To configure multiple servers:

# List the different servers
# Configure server1
# Configure server2

Authentication will be tried on each server, in the order they are listed in the configurations, until one succeeds. User/Group mapping will be performed against the first server on which the user is found.

Note that all the LDAP servers must be available while (re)starting the SonarQube server.