Keycloak SSO for SonarQube
Sign in to SonarQube Server or Community Build with Keycloak over SAML, with login, name, email and group attributes for just-in-time group sync.
SonarQube delegates sign-in to Keycloak over SAML 2.0. It does not support generic OpenID Connect, so SAML is the way to connect it to Keycloak. SAML sign-in is part of every SonarQube Server edition and of SonarQube Community Build; SCIM provisioning is only in Enterprise and Data Center editions.
Checked against the SonarQube Server 2026.5 and SonarQube Community Build docs and Keycloak 26.8 on 25 November 2026. The steps follow SonarQube's own page for Keycloak.
Replace auth.example.com with your RealmDeploy hostname and acme with your realm. The examples use https://sonarqube.example.com for SonarQube.
Before you start
Set the Server base URL in SonarQube under Administration → Configuration → General settings → General → General, for example https://sonarqube.example.com. SonarQube builds its SAML callback from it, and its docs ask for HTTPS when sign-in is delegated.
In Keycloak
Create the SAML client
Open Clients, choose Create client, and use these values:
| Setting | Value |
|---|---|
| Client type | SAML |
| Client ID | sonarqube. No spaces. SonarQube calls this value its Application ID. |
| Valid redirect URIs | https://sonarqube.example.com/oauth2/callback/saml |
Choose Save.
Then, on the client's Keys tab, turn Client signature required off. It is on by default, and SonarQube's page asks for it off. Leave Sign documents on the Settings tab on, which is the default.
Add the attribute mappers
- On the
sonarqubeclient, open the Client scopes tab and choosesonarqube-dedicated. - For each row, choose Configure a new mapper (or Add mapper → By configuration), pick User Property, fill it in and save:
| Name | Property | SAML Attribute Name | Needed by SonarQube |
|---|---|---|---|
Login | username | login | Yes |
Name | username, or another user property such as firstName | name | Yes |
Email | email | email | No |
SonarQube allows only letters, digits and ., -, _ and @ in a login, so usernames with other characters fail.
The group mapper is in Groups and roles.
Get the IdP values
Open Realm settings → General and follow the SAML 2.0 Identity Provider Metadata link at the bottom, or open it directly:
https://auth.example.com/realms/acme/protocol/saml/descriptorYou need three values from it. The SAML metadata viewer shows them, and the SAML certificate extractor pulls out the certificate.
| Value | Where in the metadata | For your realm |
|---|---|---|
| Entity ID | EntityDescriptor → entityID | https://auth.example.com/realms/acme |
| Sign-in URL | SingleSignOnService → Location | https://auth.example.com/realms/acme/protocol/saml |
| Certificate | X509Certificate | The realm's signing certificate, also under Realm settings → Keys, RS256 row, Certificate |
In SonarQube
Open Administration → Configuration → General settings → Authentication → SAML, choose Create Configuration, and fill in:
| Field | Value |
|---|---|
| Application ID | sonarqube |
| Provider Name | Keycloak, the label on SonarQube's login button |
| Provider ID | https://auth.example.com/realms/acme |
| SAML login URL | https://auth.example.com/realms/acme/protocol/saml |
| Identity provider certificate | The realm certificate |
| SAML user login attribute | login |
| SAML user name attribute | name |
| SAML user email attribute | email |
| SAML group attribute | groups, only with the group mapper below |
Save the configuration and choose Test Configuration. A new tab shows whether sign-in worked and which attributes arrived. When the test passes, choose Enable configuration.
SonarQube supports only sign-in started from SonarQube, not from Keycloak. It also does not support SAML single logout: signing out of SonarQube leaves the Keycloak session open.
Groups and roles
SonarQube's just-in-time provisioning creates each user at first sign-in and updates their group memberships at every sign-in. It does not create groups.
- In SonarQube, create the groups under Administration → Security → Groups with exactly the names used in Keycloak, case included, and give them permissions.
- In Keycloak, add one more mapper to
sonarqube-dedicatedwith Add mapper → By configuration. Use one of these:
| Your groups live in | Mapper type | Name | Group or Role attribute name | Single Group or Single Role Attribute | Full group path |
|---|---|---|---|---|---|
| Keycloak Groups | Group list | Groups | groups | On | Off |
| Realm Roles (not client roles) | Role list | Groups | groups | On | n/a |
- In SonarQube, set SAML group attribute to
groups.
Once group sync is on, Keycloak is the only place to manage memberships: memberships added by hand in SonarQube are reset at the next sign-in. Every user stays in the built-in sonar-users group.
SonarQube's docs recommend renaming the built-in sonar-administrators group when group sync is used: a Keycloak group with that name would otherwise give its members admin rights.
Optional: signed requests and encrypted assertions
SonarQube can sign its requests and Keycloak can encrypt its assertions. Both use one key pair.
- In Keycloak, on the client's Keys tab, enable Encrypt assertions in Encryption keys config and choose Generate. Your browser downloads
private.key. Keycloak keeps only the certificate. Keycloak's docs mark generating keys as deprecated and recommend making the key pair yourself and uploading only the certificate; either way SonarQube needs the private key. - Convert the key to PKCS#8 on one line, as SonarQube's page shows:
echo -e "-----BEGIN RSA PRIVATE KEY-----\n$(cat private.key)\n-----END RSA PRIVATE KEY-----" > newprivate.key
openssl pkcs8 -topk8 -in newprivate.key -out pkcs8.key -nocrypt
tr -d "\n\r" < pkcs8.key- In SonarQube, edit the SAML configuration: paste the certificate from Encryption keys config into Service provider certificate and the one-line key into Service provider private key.
- To sign requests too, turn Sign requests on in SonarQube. SonarQube's page asks for nothing more in Keycloak for this, and keeps Client signature required off.
- Choose Save configuration, then Test Configuration.
Delete private.key and pkcs8.key from your machine afterwards.
Test it
- Open
https://sonarqube.example.comin a private window. The login form now has a SAML button labeled with your Provider Name. Choose it. - Sign in as a test user. SonarQube creates the user on first sign-in.
- As an administrator, open Administration → Security → Groups and check that the user is in the groups that exist both in Keycloak and in SonarQube.
- To see the assertion, copy the
SAMLResponseform field from your browser's network tab into the SAML response decoder and check thelogin,name,emailandgroupsattributes.
Common errors
| Error | Cause | Fix |
|---|---|---|
| Keycloak shows Invalid requester | Client signature required is on, or Application ID differs from the Client ID. | Turn Client signature required off and make both IDs the same. |
| Keycloak shows Invalid redirect uri | SonarQube sent a callback that is not in Valid redirect URIs, often because Server base URL is not set or is http://. | Set Server base URL and list https://sonarqube.example.com/oauth2/callback/saml exactly. |
Found an Attribute element with duplicated Name | Keycloak's default role_list client scope sends one Role attribute per role. SonarQube's docs for earlier releases name this error. | On the client's Client scopes tab, remove role_list. |
| Test Configuration reports a missing login or name | The mapper's SAML Attribute Name differs from the SonarQube field. | Use login and name on both sides. Check the attributes with the SAML attribute reference. |
| Signature validation fails | The certificate in SonarQube is not the realm's current signing certificate. | Copy it again from the IdP metadata or Realm settings → Keys. |
| Groups do not appear | The group does not exist in SonarQube, the names differ in case, or Full group path is on. | Create the group in SonarQube with the exact name and turn Full group path off. |
FAQ
Can I use OpenID Connect instead?
No. SonarQube delegates sign-in through HTTP headers, GitHub, GitLab, Bitbucket Cloud, SAML or LDAP, not generic OpenID Connect. With Keycloak, use SAML.
Is SAML available in Community Build?
Yes. SonarQube's feature table lists SAML single sign-on in Community Build and in SonarQube Server. SCIM provisioning, which also removes users, needs Enterprise or Data Center edition and supports only Microsoft Entra ID and Okta.
Does Keycloak need an outgoing connection to SonarQube?
No. Sign-in runs through the browser, and SonarQube does not use SAML single logout.
Sources
- SonarQube Server, SAML authentication with Keycloak: https://docs.sonarsource.com/sonarqube-server/instance-administration/authentication/saml/how-to-set-up-keycloak
- SonarQube Server, Overview of SAML support (settings, limitations, group sync): https://docs.sonarsource.com/sonarqube-server/instance-administration/authentication/saml/overview
- SonarQube Server, Overview of authentication and provisioning: https://docs.sonarsource.com/sonarqube-server/instance-administration/authentication/overview
- SonarQube Server, Server base URL: https://docs.sonarsource.com/sonarqube-server/instance-administration/server-base-url
- SonarQube Server, Managing groups: https://docs.sonarsource.com/sonarqube-server/instance-administration/user-management/user-groups
- SonarQube Server, SAML setup in SonarQube (Test Configuration, Enable configuration): https://docs.sonarsource.com/sonarqube-server/instance-administration/authentication/saml/ms-entra-id/setup-in-sq
- SonarQube Community Build, SAML authentication with Keycloak: https://docs.sonarsource.com/sonarqube-community-build/instance-administration/authentication/saml/how-to-set-up-keycloak
- SonarQube Community Build, Feature comparison table: https://docs.sonarsource.com/sonarqube-community-build/feature-comparison-table
- SonarQube Server 2025.3, SAML with Keycloak (the
role_listnote): https://docs.sonarsource.com/sonarqube-server/2025.3/instance-administration/authentication/saml/how-to-set-up-keycloak - Keycloak Server Administration Guide, creating a SAML client and SAML mappers: https://www.keycloak.org/docs/latest/server_admin/
Keycloak SSO for Jenkins
Sign in to Jenkins with Keycloak through the OpenId Connect Authentication plugin, map groups to Matrix or Role-based permissions, and use JCasC.
Keycloak SSO for Nextcloud
Sign in to Nextcloud with Keycloak through the official OpenID Connect user backend app (user_oidc), with group provisioning and logout from both.