-
-
Notifications
You must be signed in to change notification settings - Fork 8
Configure Keycloak
These instructions were extracted from registered user issues. The author does not have access to a Keycloak environment to test the instructions below. Please report any incorrect instructions by creating an issue.
This guide provides a step-by-step walkthrough for configuring Keycloak as an Identity Provider (IdP) for the samlsso plugin (Service Provider) in GLPI.
This guide assumes you have administrative access to both your GLPI instance and your Keycloak realm.
The configuration is a four-part process:
- Create IdP in samlsso - Create a new IdP configuration in GLPI to get your unique SP URLs.
- Configure Keycloak Client - Create a new SAML client in Keycloak using the URLs from Part 1.
- Fix Keycloak Mappers - Adjust Keycloak's default mappers to prevent the "duplicate attribute" error.
- Finalize samlsso Configuration - Enter the Keycloak details back into the samlsso plugin.
Before you can configure Keycloak, you need to know what URLs to give it. Your plugin generates unique URLs for each IdP.
- In GLPI, navigate to Setup > Plugins > samlsso.
- Click the + icon to add a new Identity Provider.
- Give it a name, for example: Keycloak.
- Click Add.
- Find your new "Keycloak" configuration and click it.
- The new entry will provide your unique Service Provider (SP) URLs (ID, Acs, Logout) in the SP tab. Important make sure you copy these values from the config using the 'copy to clipboard' function.
- We advise NOT to use the META service because it 'leaks' important information about your setup.
Now, log in to your Keycloak admin console to create a new client.
- Navigate to the correct Realm (e.g., master).
- Go to Clients and click Create client.
- On the "Add Client" screen:
- Client type: SAML
- Client ID: This must match your SP Entity ID from Part 1.
- Name: GLPI (This is a friendly name).
- Click Next.
- On the client's Settings tab:
- Home URL: https://your-glpi.com/
- Valid redirect URIs: Add your ACS URL from Part 1.
- Master SAML Processing URL: This must also be your ACS URL.
- Still on the Settings tab, scroll down:
- NameID format: Set this to
username, depending on what you use as the GLPI login field).- Sign documents: Set to
On.- Sign assertions: Set to
On.
- Click Save.
This is a very important step. Keycloak's default behavior often sends multiple SAML attributes with the same name (e.g., email), which the onelogin/php-saml library used by the plugin correctly rejects as a security risk. This will cause a SAML validation error with SAMLSSO.
You must ensure that only one mapper exists for each attribute you send to GLPI.
- Go to the Client scopes tab for your new GLPI client.
- Click the glpi-dedicated (or similarly named) scope.
- Click the Mappers tab. You will now create your attribute mappings.
- Click Add mapper > By configuration > User Attribute.
- Create mappers for the attributes GLPI needs:
- Mapper 1: username
- Name:
username- User Attribute:
username(orsAMAccountNameif using LDAP)- SAML Attribute Name:
username- SAML Attribute NameFormat:
Basic
- Mapper 2: email
- Name:
- User Attribute:
- SAML Attribute Name:
- SAML Attribute NameFormat:
Basic
...repeat for lastname, firstname, etc.
- Go back to your GLPI client's Client scopes tab.
- Look at the list of assigned scopes. You will see your glpi-dedicated scope, but you will also see default scopes like profile.
- Click on the profile scope (or any other default scope).
- Click its Mappers tab.
- You will likely see pre-configured mappers for username, email, etc. These are the duplicates.
- Delete any mappers here that conflict with the ones you just created in your glpi-dedicated scope.
By doing this, you guarantee that only one saml:Attribute for "email" (and "username", etc.) is sent in the SAML response, which will satisfy the plugin's security validation.
- In your Keycloak admin console, go to Realm Settings.
- Click the SAML 2.0 Identity Provider Metadata link. This will open an XML file.
- Find and copy these three values:
- entityID: This is your IdP Entity ID (e.g., https://keycloak.example.com/realms/master).
- SingleSignOnService URL: The Location attribute for the HTTP-Redirect binding.
- X.509 Certificate: The large block of text inside the ds:X509Certificate tag.
- Go back to GLPI: Setup > Plugins > samlsso.
- Click on your Keycloak IdP configuration to edit it.
- Under the Identity Provider (IdP) Configuration tab:
- IdP Entity ID: Paste the entityID from Keycloak.
- Single Sign-On Service (SSO) URL: Paste the SingleSignOnService URL from Keycloak.
- Single Sign Off Service (SLO) URL: Paste the SingleSignOffService URL from Keycloak.
- x.509 Certificate: Paste the certificate data (including the ----CERT headers.)
- Under General Tab
- Check 'Enable Identity Provider'
- Click save.
Log out of GLPI. On your GLPI login page, you should now see a "Login with Keycloak" (or similar) button. Click it to test the full SAML authentication flow.