Keycloak
Prerequisites​
- Install and configure Keycloak on your server or cloud environment.
- Create a new realm in Keycloak for your application.
Get the redirectURI from Devtron​
-
Navigate to Global Configurations → Authorization → SSO Login Services. The SSO Login Service page is displayed.
Figure 1: Select OIDC -
Select OIDC from the list of available SSO login services.
-
Click the URL suggested in green color next to the Click to use label to update the URL field.
When you populate URL field, the redirectURI (or callbackURI) is updated automatically in the purple block displayed at the top of the SSO Login Service screen. This redirectURI is essential, as it is required while setting up the OAuth credentials in GitHub.
-
Copy the redirectURI from the purple block.
Figure 2: Copy Redirect URI
Steps on Keycloak Admin Console​
Creating a Client​
Here, we will add Devtron as a client for using Keycloak SSO.
-
In the Admin Console, go to Clients and click Create client.
Figure 3: Creating Client on Keycloak -
Within General Settings:
- Enter
devtronin the Client ID field. We will use this ID while configuring SSO later in Devtron. - Enter
Devtronin the Name field.
Figure 4: Client ID and Name - Enter
-
Within Capability config, turn on Client Authentication.
Figure 5: Enabling Client Authentication Toggle -
Within Login settings, enter the
redirectURIyou have copied earlier in the following fields.- Valid redirect URIs
- Valid post logout redirect URIs
- Web origins
Figure 6: Entering Callback/Redirect URIs -
Click Save.
Getting Client Secret​
Here, we will obtain the secret we need while configuring SSO in Devtron.
-
Go to the Credentials tab of the client you created.
Figure 7: Obtaining Client Secret -
Use the copy button next to the Client Secret field and paste it somewhere for future reference.
Creating Users​
Here, we will create a user that can log in to Devtron via SSO. We will assign a username and password that the user can enter while logging in to Devtron via Keycloak SSO.
-
In the Admin Console, go to Users and click Add user.
-
Give a username (e.g., usertest) in the Username field and enter the user's email address (e.g., usertest@example.com) in the Email field.
Figure 8: Creating User Data -
Click Create. Your user creation will be successful.
-
Go to the Credentials tab of the user you created.
Figure 9: Adding User Password -
Click Set password.
-
Enter the password and confirm it.
-
Click Save.
Retrieving Issuer URL​
Here, we will obtain the Issuer URL we need while configuring SSO in Devtron.
-
In the Admin Console, go to Realm settings.
-
In the General tab, scroll down to the Endpoints field, and click the OpenID Endpoint Configuration link.
Figure 10: OpenID Endpoint Configuration Link -
This will open a new page, copy the value of the key named
issuer, and paste it somewhere for future reference.
Figure 11: Locating Issuer URL
Steps on Devtron​
Configuring OIDC SSO​
Users need to have super-admin permission to configure SSO.
Here, we will set up an OIDC SSO and enter the values we obtained in the previous section.
-
Go to Global Configurations → SSO Login Services → OIDC.
-
In the Configuration editor, do the following:
- In the
issuerfield, paste the URL you got while retrieving issuer URL. - In the
clientIDfield, paste the ID you entered while creating the client. - In the
clientSecretfield, paste the secret you got under client credentials tab. - In the
redirectURIfield, make sure to enter the same redirect URI you gave in step 4 of client creation.
Figure 12: Sample Keycloak SSO Config - In the
-
Click Save or Update to activate Keycloak SSO login.
Adding Users​
Users need to have super-admin permission to add users.
Here, we will add the user we created in the Keycloak Admin Console. If this step is skipped, the user might not be able to log in to Devtron via Keycloak.
-
Go to Global Configurations → Authorization → User Permissions.
-
Click + Add Users.
Figure 13: Adding Users to Devtron -
In the Email addresses field, enter the email address of the user you created in Keycloak.
Figure 14: Entering User Data and Permissions -
Assign necessary permissions to this new user. Refer user permissions to know more.
-
Click Save.
Now, you may log out and test the Keycloak OIDC login method using the user credentials. Clicking the Login with Oidc button will land you on Keycloak's login page.
Kindly get in touch with us if you encounter any issues while logging out of Keycloak on Devtron as it might be buggy.