Keycloak
Use a SAML client in a Keycloak realm. The preset uses the X500 attribute names of the Keycloak mappers.
Preset values
Section titled “Preset values”The Keycloak preset fills in these attributes:
| Field | Attribute |
|---|---|
| Email Attribute | urn:oid:1.2.840.113549.1.9.1 |
| First Name Attribute | urn:oid:2.5.4.42 |
| Last Name Attribute | urn:oid:2.5.4.4 |
| Group Attribute | Role |
The import selects this preset when the IdP entity ID ends with /realms/<realm>.
Before you start
Section titled “Before you start”Create the provider in Magento, and save it as inactive. Copy the SP Entity ID and the ACS URL from the Service Provider fieldset.
Configure Keycloak
Section titled “Configure Keycloak”-
In the Keycloak admin console, select the realm.
-
Create a client of the type SAML.
-
In Client ID, enter the SP Entity ID of Magento.
-
Enter the ACS URL of Magento as the assertion consumer service POST binding URL.
-
In Name ID format, select email.
-
Make sure that Keycloak signs the assertions. Refer to the caution below.
-
Add the X500 email, X500 givenName and X500 surname mappers to the client.
-
Download the IdP metadata of the realm. The usual path is
/realms/<realm>/protocol/saml/descriptor.
Keycloak settings at a glance
Section titled “Keycloak settings at a glance”| Keycloak setting | Value |
|---|---|
| Client type | SAML |
| Client ID | SP Entity ID |
| Assertion Consumer Service POST Binding URL | ACS URL |
| Name ID format | |
| Sign assertions | On, unless Magento requires only a signed response |
| IdP metadata | /realms/<realm>/protocol/saml/descriptor. Import this file in Magento. |
| Attribute name | Source at Keycloak | Note |
|---|---|---|
urn:oid:1.2.840.113549.1.9.1 |
X500 email mapper | Client mapper |
urn:oid:2.5.4.42 |
X500 givenName mapper | Client mapper |
urn:oid:2.5.4.4 |
X500 surname mapper | Client mapper |
Role |
Role list mapper | Default |
member |
Group list mapper | Optional. Replaces Role as the group attribute. |
The attribute names must be exactly the same as in the Magento attribute mapping. To see the names that Keycloak sends, test the provider.
Configure Magento
Section titled “Configure Magento”-
Open the provider in Magento.
-
Click Import Metadata, and select the metadata file of Keycloak.
-
In Attribute Mapping > Load Preset, select Keycloak, if the import did not select it.
-
Examine the imported values, and the note of the preset.
-
In Your Password, enter your current admin password.
-
Click Save and Continue Edit.
-
Click Test Connection, and sign in with a test user.
-
If the test succeeds, turn on Active, and save the provider again.
-
Add and verify the domain of the users.
Groups and roles
Section titled “Groups and roles”The default role list mapper sends the roles in the Role attribute. To map groups instead, add a Group list mapper. It sends the full group paths, such as /staff/admins, in the member attribute. Then set Group Attribute to member. For the role rules, refer to Role mapping.
Two-factor authentication
Section titled “Two-factor authentication”Keycloak does not send the authentication methods over SAML. Thus the two-factor authentication of Magento applies. The exception is a step-up authentication that maps the level of a WebAuthn sign-in to the SmartcardPKI authentication context class.
Common problems
Section titled “Common problems”| Problem | Solution |
|---|---|
| The login fails with “The assertion is not signed.” | Keycloak signs only the response. Refer to the caution above. |
For more problems, refer to Troubleshooting.