SAML Single Sign On (SSO) into SonarQube using Keycloak
SonarQube SAML plugin gives the ability to enable SAML Single Sign On for the SonarQube. Here we will go through a guide to configure SSO between SonarQube and KeyClock. By the end of this guide, KeyClock users should be able to log in and register to the SonarQube Server.
Video Setup Guide
Pre-requisites
- You'll require SP metadata for IDP configuration.
- You can find it under Administration >>Configuration >>miniOrange SAML Support >> SP Metadata tab.
- The SP metadata can be used manually or using 2 Different Format options Text or File.

Step 1: Set Up Keycloak as Identity Provider
Select Keycloak version:
Configure Keycloak as IdP
- In your Keycloak Admin console, select the realm that you want to use.
- Click on Clients from the left menu and then click on Create button to create a new client/application.
- Enter SP-EntityID / Issuer as the Client ID from the "Service Provider Metadata" Tab and select SAML as the Client Protocol.
- Now click on Save.
- Configure Keycloak by providing the required details:
- Under Fine Grain SAML Endpoint Configuration, Enter the following details:
- Click on Save.
- In your Keycloak Admin console, select the realm that you want to use.
- Click on Clients from the left menu and then click on Create Client button to create a new client/application.
- Select SAML as Client type, Enter SP-EntityID / Issuer as the Client ID from the "Service Provider Metadata" Tab,Enter Name of your application and enter Description.
- Now click on Save.
- Configure Keycloak by providing the required details:
- Now click on Save.
- In Advanced tab, under Fine Grain SAML Endpoint Configuration, Enter the following details:
- Click on Save.
- In your Keycloak Admin console, select the realm that you want to use.
- Click on Clients from the left menu and then click on Create Client button to create a new client/application.
- Select SAML as Client type, Enter SP-EntityID / Issuer as the Client ID from the Service Provider Metadata tab, enter Name of your application and enter Description.
- Click on the Next button.
- Provide the details as mentioned below:
- Click on Save button.
- In the Settings tab under SAML capabilities section, configure Keycloak by providing the required details:
- In the Keys tab, disable the Client signature required toggle.
- Click on the Save button.
- In Advanced tab, under Fine Grain SAML Endpoint Configuration, enter the following details:
- Click on Save button.


Client ID | The SP-EntityID / Issuer from the plugin's Service Provider Metadata tab |
Name | Provide a name for this client |
Description | Provide a description |
Client Signature Required | OFF |
Force POST Binding | OFF |
Force Name ID Format | OFF |
Name ID Format | |
Root URL | Leave empty or Provide Base URL from Service Provider Metadata tab |
Valid Redirect URIs | The ACS (Assertion Consumer Service) URL from the plugin's Service Provider Metadata tab |


Assertion Consumer Service POST Binding URL | The ACS (Assertion Consumer Service) URL from the plugin's Service Provider Metadata tab |
Logout Service Redirect Binding URL (Optional) | The Single Logout URL from the plugin's Service Provider Metadata tab |



Client ID | The SP-EntityID / Issuer from the plugin's Service Provider Metadata tab |
Name | Provide a name for this client |
Description | Provide a description |
Client Signature Required | OFF |
Force POST Binding | OFF |
Force Name ID Format | OFF |
Name ID Format | |
Root URL | Leave empty or Provide Base URL from Service Provider Metadata tab |
Valid Redirect URIs | The ACS (Assertion Consumer Service) URL from the plugin's Service Provider Metadata tab |



Assertion Consumer Service POST Binding URL | The ACS (Assertion Consumer Service) URL from the plugin's Service Provider Metadata tab |
Logout Service Redirect Binding URL (Optional) | The Single Logout URL from the plugin's Service Provider Metadata tab |



Root URL | Leave empty or provide Base URL from Service Provider Metadata tab |
Valid Redirect URIs | The ACS (Assertion Consumer Service) URL from the plugin's Service Provider Metadata tab |

Force POST Binding | OFF |
Force Name ID Format | OFF |
Name ID Format |


Assertion Consumer Service POST Binding URL | The ACS (Assertion Consumer Service) URL from the plugin's Service Provider Metadata tab |
Logout Service Redirect Binding URL (Optional) | The Single Logout URL from the plugin's Service Provider Metadata tab |

Add Mappers
- Navigate to Mappers tab and click on Add Builtin button.
- Select the checkboxes of X500 givenName, X500 surname and X500 email attributes.
- Click on Add Selected button. You will see the mappings that are added below.
- In Client scopes tab,click on your application.
- Click on Add predefined mapper.
- Select the checkboxes of X500 givenName, X500 surname and X500 email attributes.
- Click on Add button.
- You will see the mappings that are added below.
- In the Client scopes tab, click on your application.
- Click on Add predefined mapper.
- Select the checkboxes of X500 givenName, X500 surname and X500 email attributes.
- Click on the Add button.
- You will see the mappings that are added below.











Download setup file
- Navigate to Realm Settings, click on SAML 2.0 Identity Provider Metadata mentioned as Endpoints in the General Tab.
- Note the URL and keep it handy. That will provide you with the Endpoints required to configure the plugin.
- Navigate to Realm Settings, click on SAML 2.0 Identity Provider Metadata mentioned as Endpoints in the General Tab.
- Note the URL and keep it handy. That will provide you with the Endpoints required to configure the plugin.
- Navigate to Realm Settings, click on SAML 2.0 Identity Provider Metadata mentioned as Endpoints in the General tab.
- Note the URL and keep it handy. That will provide you with the Endpoints required to configure the plugin.



Step 2: Set Up SonarQube as Service Provider
Fetch the Identity Provider (IdP) Details
- After configuring the IdP, get its metadata to configure SonarQube as a Service Provider(SP).
-
Copy the following details from the IdP metadata and paste them
into the corresponding text fields in the SonarQube plugin.
- IdP Entity ID
- Login URL
- X.509 Certificate
- Save all the details.

Test Configuration
- Once you have filled all the IdP details, go to Administration >>Configuration >>miniOrange SAML Support and then click on the Test Configuration tab.
- It will show you the IdP login page. Enter your IdP credentials and log in.
- If all the configurations are correct, it will show you the user details received from the IdP.
- If the test fails, check if you have missed out any steps or try to debug through SonarQube .
- To be able to troubleshoot through logs, first you'll have to set a higher log level in your SonarQube application.
- To do so, go to the SonarQube Dashboard >> Administration >> System.
- Under the system settings, you'll find an option to change the log's level. Select DEBUG and save it. Now try to configure the plugin.
- If you face any problem during configuration, go to %SONARQUBE_HOME% / logs directory.
- Find and open the web.log file. Go through the logs recorded.
- You'll find the stacktrace of performed actions, along with date and time information.

Attribute & Group Mapping
- In order to map attributes from the Identity Provider to the application, the attribute names received in the SAML response need to be entered in their corresponding fields.
- To view these attribute names, click on the Test Configuration tab in the plugin support page.
-
Attributes used in SonarQube Application are described briefly as
below:
- Login Attribute is a unique name assigned to the user to identify them uniquely within the SonarQube system. It's a required attribute.
- Name Attribute is the full name of the user, to be mapped from the IdP to the SonarQube. It's a required attribute.
- Email Attribute is an optional attribute and represents an email address of the user, to be mapped from the IdP to the SonarQube.
- Group Attribute mapping requires the group names, in the application, to be same as the group names in the Identity Provider. Otherwise, the default SonarQube Group is assigned to the user.
- Eg. To map group value Everyone from SAML response we have to paste groupName in Group Attribute field.

Additional Resources
Did this page help you?
