SonarQube comes with an onboard user database, as well as the ability to delegate authentication via HTTP Headers, GitHub Authentication, GitLab Authentication, SAML, or LDAP. Each method offers user identity management, group synchronization/mapping, and authentication.
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-usersremains (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 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. See the
SSO AUTHENTICATION section within
When this feature is activated, SonarQube expects that the authentication is handled prior to 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
All the parameters required to activate and configure this feature are available in SonarQube server configuration file (in
Using HTTP header authentication is an easy way to integrate your SonarQube deployment with an in-house SSO implementation.
GitHub, GitLab, and Bitbucket Cloud authentication
You can delegate authentication to GitHub, GitLab, or Bitbucket Cloud. See the corresponding DevOps Platform integration page for more information:
You can delegate authentication to a SAML 2.0 Identity Provider using SAML Authentication.
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.
SAML and reverse proxy configuration
When using SAML, make sure your reverse proxy is properly configured. See Operating the Server for more information.
You can configure SonarQube authentication and authorization to an LDAP server (including LDAP Service of Active Directory) by configuring the correct values in
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|
Y = successfully tested
- Configure LDAP by editing
<SONARQUBE_HOME>/conf/sonar.properties(see table below).
- Restart the SonarQube server and check the log file for:
- Log into SonarQube
- 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.
|Set this to ||none||Yes|
|Set to true when connecting to a LDAP server using a case-insensitive setup.||No|
|URL of the LDAP server. If you are using ldaps, you should install the server certificate into the Java truststore.||none||Yes|
|The username of an LDAP user to connect (or bind) with. Leave this blank for anonymous access to the LDAP directory.||none||No|
|The password of the user to connect with. Leave this blank for anonymous access to the LDAP directory.||none||No|
|Possible values: ||No|
|See Digest-MD5 Authentication, CRAM-MD5 Authentication||none||No||example.org|
|Context factory class.||No|
|Enable use of ||No|
|Follow referrals or not. See Referrals in the JNDI|
|Property||Description||Default value||Required||Example for Active Directory|
|Distinguished Name (DN) of the root node in LDAP from which to search for users.||None||Yes|
|LDAP user request.||No|
|Attribute in LDAP defining the user’s real name.||No|
|Attribute in LDAP defining the user’s email.||No|
Group Mapping Only groups (not roles) and static groups (not dynamic groups) are supported. Click here for more information.
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|
|LDAP group request.||No|
|Property used to specifiy the attribute to be used for returning the list of user groups in the compatibility mode.||No|
Advanced LDAP Topics
Anonymous- Used when only read-only access to non-protected entries and attributes is needed when binding to the LDAP server.
SimpleSimple 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.
To configure multiple servers:
Authentication will be tried on each server, in the order that they are listed in the configuration 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.
Migrate users to a new authentication method
If you are changing your delegated authentication method and migrating existing users from your previous authentication method, you can use the
api/users/update_identity_provider web API to update your users' identity provider.
- Detailed connection logs (and potential error codes received from LDAP server) are output to SonarQube's
<SONARQUBE_HOME>/logs/web.logwhen logging is in
- Time out when running SonarQube analysis using LDAP Java parameters are documented here: http://docs.oracle.com/javase/jndi/tutorial/ldap/connect/config.html. Such parameters can be set in
Revoking tokens for deactivated users
When SonarQube authentication is delegated to an external identity provider (LDAP, SAML, GitHub, or GitLab), deactivating a user on the identity provider side does not remove any tokens associated with the user on the SonarQube side. We recommend deactivating the user in SonarQube at Administration > Security > Users by selecting Deactivate from the gear drop-down menu to ensure tokens associated with that user can no longer be used.
© 2008-2022, SonarSource S.A, Switzerland. Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution-NonCommercial 3.0 United States License. SONARQUBE is a trademark of SonarSource SA. All other trademarks and copyrights are the property of their respective owners.