1) Install and configure Keycloak
Download and install the latest Keycloak distribution (tested with 1.8.0). Start keycloak in standalone mode by running 'sh bin/standalone.sh'.
1.1) Create users in Keycloak
First we need to create an admin user by navigating to the following URL, and entering a password:
- http://localhost:8080/auth/
1.2) Create a new client application in Keycloak
Now we will create a new client application for the Fediz IdP in Keycloak. Select "Clients" in the left-hand menu, and click on "Create". Specify the following values:
- Client ID: urn:org:apache:cxf:fediz:idp:realm-A
- Client protocol: saml
- Client SAML Endpoint: https://localhost:8443/fediz-idp/federation
- Select "Sign Assertions"
- Select "Force Name ID Format".
- Valid Redirect URIs: https://localhost:8443/*
- Archive Format: JKS
- Key Alias: realma
- Store password: storepass
- Import file: stsrealm_a.jks
Finally, we need to export the Keycloak signing certificate so that the Fediz IdP can validate the signed SAML Response from Keycloak. Select "Realm Settings" (for "realmb") and click on the "Keys" tab. Copy and save the value specified in the "Certificate" textfield.
2) Install and configure the Apache CXF Fediz IdP and sample Webapp
Follow a previous tutorial to deploy the latest Fediz IdP + STS to Apache Tomcat, as well as the "simpleWebapp". Test that the "simpleWebapp" is working correctly by navigating to the following URL (selecting "realm A" at the IdP, and authenticating as "alice/ecila"):
- https://localhost:8443/fedizhelloworld/secure/fedservlet
Now we will configure the Fediz IdP to authenticate the user in "realm B" by using the SAML SSO protocol. Edit 'webapps/fediz-idp/WEB-INF/classes/entities-realma.xml'. In the 'idp-realmA' bean:
- Change the port in "idpUrl" to "8443".
- Change the "url" value to "http://localhost:8080/auth/realms/realmb/protocol/saml".
- Change the "protocol" value to "urn:oasis:names:tc:SAML:2.0:profiles:SSO:browser".
- Change the "certificate" value to "keycloak.cert".
Copy 'webapps/fediz-idp/WEB-INF/classes/realmb.cert' to a new file called 'webapps/fediz-idp/WEB-INF/classes/keycloak.cert'. Edit this file + delete the content between the "-----BEGIN CERTIFICATE----- / -----END CERTIFICATE-----" tags, pasting instead the Keycloak signing certificate as retrieved in step "1.3" above.
The STS also needs to trust the Keycloak signing certificate. Copy keycloak.cert into 'webapps/fediz-idp-sts/WEB-INF/classes". In this directory import the keycloak.cert into the STS truststore via:
- keytool -keystore ststrust.jks -import -file keycloak.cert -storepass storepass -alias keycloak
3) Testing the service
To test the service navigate to:
- https://localhost:8443/fedizhelloworld/secure/fedservlet
No comments:
Post a Comment