Configure MS ADFS 3.0 as Brokered Identity Provider in Keycloak¶
Configure the Keycloak Server for SSL/TLS Transport¶
- Set the Keycloak HTTPS port to
443. - In order to enable outgoing HTTPS connections, export the ADFS certificate into a Java truststore:
- In the ADFS management console, go to
Service/Certificates nodeand export the service communications certificate. - Import the certificate into a Java truststore (JKS format) using the Java keytool utility.
- Setup the truststore in Keycloak as described in Keycloak Server Installation.
- In the ADFS management console, go to
Configure the Identity Provider in Keycloak¶
Configure Basic Properties of a Brokered Identity Provider¶
-
Open the Keycloak web interface.
-
Log on as administrator.
-
Click
Identity Providersand add a new SAML v.2.0 provider.Hint - memorize alias
Do not forget the provider alias you entered, you will need it later!
-
Scroll to the bottom of the page.
-
In
Import from URL, enter the ADFS descriptor URL:https://<ADFSdomainname>/FederationMetadata/2007-06/FederationMetadata.xml
-
Click
Importand check the settings.- The following settings are to be enabled:
Backchannel LogoutHTTP-POST Binding ResponseHTTP-POST Binding for AuthnRequestValidate Signature
- The following settings are to be enabled:
-
If the authentication requests sent to the ADFS instance are expected to be signed, enable the
Want AuthnRequests Signedoption. Set theSAML Signature Key Namefield, that shows after enabling theWant AuthnRequests Signedoption toCERT_SUBJECT, because ADFS expects the signing key name hint to be the subject of the signing certificate. -
If the ADFS is set up to respond with
nameID in the Windows Domain Qualified Name format, set theNameID Policy Formatfield accordingly.
Configure Mappers¶
ADFS sends email information in SAML assertion.
To transform these and other details from SAML document issued by ADFS to the Keycloak user store, set up mappers in the Mappers tab of the identity provider:
-
For
emailthe mapper is of typeAttribute Importer. Map the user attributeemailtohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress. -
For
usernamethe mapper is of typeUsername Template Importer. Map the user attributeusernameto${ATTRIBUTE.http://schemas.microsoft.com/2012/12/certificatecontext/field/subjectname}. -
For
surnamethe mapper is of typeAttribute Importer. Map the user attributelastNametohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname. -
For
given namethe mapper is of typeAttribute Importer. Map the user attributefirstNametohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname.
Obtain Information for the ADFS Configuration¶
-
Specify the SAML service provider descriptor URI that is used in ADFS setup from the
Redirect URIfield in the identity provider by adding/descriptorto the URI in this field. -
The URI is similar to
-
https://<Keycloak domain name>/auth/realms/master/broker/<identity provider alias>/endpoint/descriptor.Hint - URI check
Check the naming of the URI by entering the URI into the browser. As a result, you should receive a SAML service provider XML descriptor.
-
Configure Relying Party Trust in ADFS¶
Configure Relying Party¶
-
In the ADFS management console, click
Trust relationships/Relying Party Trusts. -
Select
Add Relying Party Trust. -
A wizard opens.
-
Enter the SAML descriptor URL obtained in the previous step into the
Federation metadataaddress field. -
Import the ADFS the settings.
-
Proceed with the wizard, and adjust the settings where appropriate.
Hint - further settings
Use only the default settings. You have to edit the
claim rules. Leave the checkbox of the last page of the wizard on.
Configure Claim Mapping¶
Now, the SAML protocol would proceed correctly, ADFS would be able to correctly authenticate the users according to requests from Keycloak but the requested name ID format is not yet recognized and SAML response would not contain any additional information like e-mail. It is hence necessary to map claims from AD user details into SAML document.
We will set up two rules: one for mapping the user ID and a second one for mapping the standard user attributes. All start by clicking the Add Rule button in the Edit Claim Rules dialog.
Rule for Mapping user ID¶
- Open the
Edit Claim Rulesdialog. - In the
Add Transform Claim Ruledialog, selectTransform an incoming claim. -
Map the following attributes:
Name IDasrule nameWindows account namefor propertyIncoming claim typeName IDfor propertyOutgoing claim typeWindows qualified Domain Namefor propertyOutgoing name ID format
-
Click
Finishto add the rule.
Rule for Mapping the Attributes of the Standard User¶
- Open the
Edit Claim Rulesdialog. - In the
Add Transform Claim Ruledialog, selectSend LDAP attributes as Claims rule. -
Map the following attributes:
E-Mail-AddressestoE-Mail AddressSAM-Account-NametoSubject Name- Your LDAP attributes for
surnameandgiven name
-
Add other attributes if needed.
Troubleshooting¶
Check the Communication between Keycloak and ADFS¶
-
Check if SAML messages are sent back and forth between Keycloak and ADFS in your a web browser and capture the communication messages. From the captured communication, you see the error status codes and the actual attribute names and values in SAML assertion necessary for setting up mappers.
Hint - SAML decoders
The SAML decoders are available as browser extensions (e. g. SAML Tracer for Firefox, SAML Chrome Panel for Google Chrome).
Example - unrecognized name ID format
Unless the name ID format is recognized, ADFS returns a SAML response containing the
urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicystatus code.
Check the Log Files¶
- The ADFS log files are available in the event viewer:
Applications and Services Logs/ADFS/Admin
- For Keycloak, enable tracing of the SAML processing by connecting to the running Keycloak instance:
jboss-cli.sh
-
Enter the following commands:
/subsystem=logging/logger=org.keycloak.saml:add(level=DEBUG) /subsystem=logging/logger=org.keycloak.broker.saml:add(level=DEBUG)SAML messages and broker-related SAML processing messages are displayed in the Keycloak server log.
Literature - SEAL Print Client knowledge base
For further information and known problems, refer to SEAL Print Client Knowledge Base.