Configure OIDC on Rancher
Create the keycloak ressources
This can be done either by following rancher documentation on Keycloak OIDC
or by using the KeycloakImporter Helm Chart with the provided values keycloak-import-values.yaml.
Tis values is not complete ! You need to provide the following (their placement can be found by searching <anchor> in the file) :
- a username and password to connect to keycloak with enough permissions to add client, groups and users.
- a password for the user rancher-admin
Once you have replaced the placeholders you can use the KeycloakImporter Helm Chart :
# For the sake of this command, we consider that both rancher and keycloakimporter are in the same folder
helm upgrade --install --namespace cattle-system -f keycloak-import-values.yaml keycloakimporter-rancher ../keycloakimporter/keycloakimporter
Activate OIDC in rancher UI
First you need to connect to keycloak to retrieve configuration informations :
- Select the realm
kosmosin the upper left corner - Click on
Clientsin the left panel to show the client list and then and onrancherin this list - Click on the tab
Credentialsand retrieve theClient Secret - Click on
Realm Settingson the left panel and then at the bottom of the settings click on theOpenID Endpoint Configurationlink. - Keep the new browser tab open
Then connect to Rancher UI and connect with an admin user :
- Click on the user icon in the bottom left corner
- Click on the
Auth providertab in the new left panel - Click on the
Keycloaklabeled with an orangeOIDC - Fill the fields in the
Configure a Keycloak OIDC accountsection :- the
Client IDisrancher - the
Client Secretis the one retrieved in the Keycloak UI previously (step 3) - do not fill the
Private KeyandCertificatefields
- the
- In the
Endpointssection selectSpecify, click on theShow Advancedbutton and have your keycloakOpenID Endpoint Configurationnearby :- leave the
Rancher URLas is Issuer: paste the value from the fieldissuerin keycloak configurationAuth Endpoint: paste the value from the fieldauthorization_endpointin keycloak configurationToken Endpoint: paste the value from the fieldtoken_endpointin keycloak configurationUser Info Endpoint: paste the value from the fielduserinfo_endpointin keycloak configurationJWKS URL&Authorization COntext Reference: do not fill
- leave the
- Click on
Saveand when asked to, authenticate with therancher-admin@athea.techuser- the password can be retrieved with the command :
kubectl -n cattle-system get secret rancher-admin-oidc -o jsonpath='{.data.password}' | base64 --decode ; echo
With the OIDC now active you can setup basic authorizations :
- While on the
Authentication Provider:Keycloak (OIDC)result page click onRestrict access to only the authorized users & groups - In the new
Authorized Users & Groupssection, add the following groups and click onSave- adminsysteme
- adminsecurite
- admininfra
- In the left panel click on
Groups - In the new menu, click on the
Assign Global Roles - In
Select Memberchoose theadminsystemegroup, and give it the global permissionsAdministratorand click onSave - In the new menu, click on the
Assign Global Roles - In
Select Memberchoose theadminsecuritegroup, and give it the global permissionsAdministratorand click onSave - In the new menu, click on the
Assign Global Roles - In
Select Memberchoose theadmininfragroup, and give it the global permissionsAdministratorand click onSave