Sonarqube SSO Configuration
Prerequisites
- Ensure the Global SSO Settings have already been configured for this cluster.
- Access to Keycloak Master Realm
Create Keycloak Client
- While you are in the
smoothglue
realm, click onClients
underManage
in the left pane. - Click
Create client
. - Select
SAML
forClient type
. - Enter client name
sonarqube
forClient ID
. - Click on the
Next
button. Note: The application's FQDN name may be obtained by runningkubectl get virtualservice -A
- Enter
https://{{ application_fqdn }}/oauth2/callback/saml
forValid Redirect URIs
. - Click on the
Save
button. - Go to
Keys
tab. - Disable
Client signature required
->Yes
.
Creating Client Scopes
Sonarqube
needs to be added in the Client Scopes.
- While you are in the
smoothglue
realm, click onClient Scopes
. - Click
Create client scope
. - Enter
Sonarqube
forName
. - Select
SAML
forProtocol
, and click on theSave
button. - Go to the
Mappers
tab. - Click on
Configure a new mapper
->User Property
. - Enter the following information:
- Name -
Login
- Property -
username
- Leave
Friendly Name
blank - SAML Attribute Name -
login
- SAML Attribute NameFormat -
Basic
- Save
- Click
Client scope details
near the top of the screen.
- Name -
- Click on
Add mapper
,By configuration
,User Property
. - Enter the following information:
- Name -
Name
- Property -
username
- Leave
Friendly Name
blank - SAML Attribute Name -
name
- SAML Attribute NameFormat -
Basic
- Save
- Name -
- Click on
Add mapper
,By configuration
,User Property
. - Enter the following information:
- Name -
Email
- Property -
email
- Leave
Friendly Name
blank - SAML Attribute Name -
email
- SAML Attribute NameFormat -
Basic
- Save
- Name -
- Click on
Add mapper
,By configuration
,Group list
. - Enter the following information:
- Name -
Groups
- Group attribute name -
groups
- Leave
Friendly Name
blank - SAML Attribute NameFormat -
Basic
- Single Group Attribute - Enabled
- Full group path - Enabled
- Save
- Name -
- Go to
Clients
, and click on thesonarqube
client. - Go to the
Client Scopes
tab. - Click
Add client scope
. - Enable the
Sonarqube
client scope. - Click
Add
->Default
. - Click the kebab icon (3 vertical dots) on the
role_list
row and clickRemove
->Delete
.
Failing to remove the role_list
Client Scope will cause the SonarQube container to throw the following error when attempting to log in:
com.onelogin.saml2.exception.ValidationError: Found an Attribute element with duplicated Name
SSO Configuration
Retrieve the secured
key value from the Keycloak client:
- As a Keycloak Admin and within the
smoothglue
realm, clickRealm Settings
on the left-hand panel. - Click on the
Keys
tab. - Click on the
Certificate
button on the R256 row.
Add the following values to bigbang-secrets.yaml
to configure SSO:
addons:
sonarqube:
enabled: true
sso:
enabled: true
# The base URL of the sonarqube server
serverBaseURL: "https://{{sonarqube_url}}"
# The client ID of the Sonarqube client in Keycloak
client_id: "sonarqube"
# You will find this in Keycloak in Realm Settings > General > Endpoints. Click on SAML 2.0 Identify Provider Metadata to obtain the XML configuration file. Search for the value 'EntityDescriptor > entityID'
providerid: "https://{{keycloak_url}}/auth/realms/smoothglue"
# This can be found in the Endpoint SAML metadata as `SingleSignOnService`
loginUrl: "https://{{keycloak_url}}/auth/realms/smoothglue/protocol/saml"
# This is the RS256 key copied from Keycloak
certificate: ""
# These are set to the SAML attributes defined in Client Scopes
login: "login"
name: "name"
email: "email"
group: "groups"
See How to Configure Big Bang Values for more information on configuring Big Bang applications.
Configure SonarQube SSO Admin Group
SonarQube will automatically create users in its datastore if they do not exist, but it will not automatically create groups. Groups MUST be manually created to have users automatically placed into them at login.
SmoothGlue comes preconfigured with a _structsureAdmins
group within Keycloak for assigning users admin privileges across the platform. A System Integrator is responsible for creating the an associated group within SonarQube and assigning the correct permissions to the group.
Login with Admin Credentials
The default admin username is admin
and a randomly generated password can be retrieved from the cluster. It is stored in the sonarqube-sonarqube-admin-password
Kubernetes secret in the sonarqube
namespace.
Create SSO Admin Group
After signing in as the default Admin account:
- Click
Administration
. - Go to
Security
->Groups
. - Click
Create Group
. - Name the group
/_structsureAdmins
Assign Admin Privileges to SSO Admin Group
After signing in as the default Admin account:
- Click
Administration
. - Go to
Security
->Global Permissions
. - For the
/_structsureAdmins
group, assign all of the permissions that thesonar-administrators
has.