Configure RH-SSO to secure applications from multiple identity providers, by using user federation and social logins.
Outcomes
Add Red Hat Identity Management (IdM) as a LDAP user federation provider in RH-SSO.
Synchronize users between RH-SSO and IdM.
Add Red Hat OpenShift as an identity provider in RH-SSO.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start identity-review
Procedure 4.3. Instructions
Run the finance-webapp application and test the jsmith user authentication.
The password for the jsmith user is redhat.
You can find the application in the ~/DO313/labs/identity-review/finance-webapp directory.
Run the application by using the mvn install && java -jar target/quarkus-app/quarkus-run.jar command.
The finance web application URL is http://localhost:8080/finance.
The user authentication fails because the user is present in IdM but it is not present in RH-SSO.
Open the terminal application on the workstation machine and change to the ~/DO313/labs/identity-review/finance-webapp directory.
[student@workstation ~]$ cd ~/DO313/labs/identity-review/finance-webappFrom the terminal, compile and run the application.
[student@workstation finance-webapp]$mvn install && \ java -jar target/quarkus-app/quarkus-run.jar...output omitted... 2023-01-18 05:39:03,454 INFO [io.quarkus] (main)finance-webapp 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.14.0.Final) started in 2.358s. Listening on: http://0.0.0.0:8080 2023-01-18 05:39:03,457 INFO [io.quarkus] (main) Profile prod activated. 2023-01-18 05:39:03,457 INFO [io.quarkus] (main) Installed features: [cdi, oidc, qute, reactive-routes, resteasy, resteasy-qute, security, servlet, smallrye-context-propagation, smallrye-jwt, vertx]
Leave the terminal open.
Open a Firefox tab and navigate to the finance web application URL at http://localhost:8080/finance.
Click Show my access token.
Try to log in with the jsmith user, with redhat as the password.
The authentication fails because the jsmith user is present in IdM, but it is not present in RH-SSO.
Close the tab.
Add a LDAP user federation provider to federate IdM.
The RH-SSO web UI URL is https://sso.lab.example.com:8080 and you can log in as the admin user with redhat as the password.
Create the LDAP IdM user federation provider with the following parameters.
RH-SSO should be able to modify the user parameters and synchronize them to IdM.
| Parameter | Value |
|---|---|
| Console Display Name | LDAP IdM |
| Edit Mode | WRITABLE |
| Vendor | Red Hat Directory Server |
| UUID LDAP attribute | ipaUniqueID |
| Connection URL | ldap://idm.ocp4.example.com |
| Users DN | cn=users,cn=accounts,dc=ocp4,dc=example,dc=com |
| Bind DN | uid=admin,cn=users,cn=accounts,dc=ocp4,dc=example,dc=com |
| Bind Credential | r3dh4t12342022 |
Test the jsmith user authentication in the finance-webapp application.
It should succeed now.
On the workstation machine, use Firefox to navigate to the RH-SSO web UI URL at https://sso.lab.example.com:8080.
Click .
Log in as the admin user with redhat as the password.
By default, the main page shows the menu for the rhtraining realm.
Click → .
Click and select ldap.
Complete the user federation provider parameters just like the previous table. Scroll down and then click .
Click . A pop-up shows that one user is imported to RH-SSO.
Open a new Firefox private window and navigate to the finance web application URL at http://localhost:8080/finance.
Click Show my access token.
Try to log in as the jsmith user with redhat as the password.
The authentication must succeed.
Close the tab.
In RH-SSO, verify that the First Name field for the user is not correctly imported because it should be Jane instead of Jane Smith.
Modify the User Federation mappers to correctly import the first name from IdM.
The IdM web UI URL is https://idm.ocp4.example.com and you can log in as the admin user with r3dh4t12342022 as the password.
Open a new Firefox tab and navigate to the IdM web UI URL at https://idm.ocp4.example.com.
Log in as the admin user with r3dh4t12342022 as the password.
By default, the main page shows the menu.
Verify that jsmith is an active user on IdM by looking at the enabled users.
Verify that the first name for the jsmith user is Jane.
Change to the RH-SSO Firefox tab.
Click → . Click .
Click the jsmith user ID.
Verify that the First Name field is not correctly imported because it must be Jane.
Modify the User Federation mappers to correctly import the first name from IdM.
Click → .
Click LDAP IdM.
Click the tab.
Click the first name mapper.
Modify the LDAP Attribute field to givenname.
Click .
Update the user fields.
Click → .
Click LDAP IdM.
Click .
A pop-up shows that one user is updated.
Verify the first name for the jsmith user is correct.
Click → .
Click the ID field for the jsmith user.
Verify that the First Name field is correctly imported.
In RH-SSO, update the jsmith user first name to Jane Q.
Update the email to jsmith@redhat.com.
Verify that both fields update in IdM.
Create the Red Hat OpenShift identity provider in RH-SSO, with OpenShift as the display name.
To do so, create the rhsso-identity project on Red Hat OpenShift and a OAuthClient custom resource.
The name for the OAuthClient custom resource must be ocp-identity and the secret mysecret.
You can find the ocp-identity.yaml file that contains the definition of a OAuthClient custom resource in the ~/DO313/labs/identity-review directory.
You can log in to Red Hat OpenShift cluster as the admin user with redhat as the password in the Red Hat OpenShift API URL at https://api.ocp4.example.com:6443.
Create the Red Hat OpenShift identity provider in RH-SSO.
To do so, change to the RH-SSO Firefox tab.
Click → .
Select Openshift v4.
Copy the Redirect URI field.
Do not click yet.
Open a new terminal window on the workstation machine.
Log in to the ocp4.example.com cluster as the admin user.
[student@workstation ~]$ oc login -u admin -p redhat \
https://api.ocp4.example.com:6443Create the rhsso-identity project.
[student@workstation ~]$ oc new-project rhsso-identity
Now using project "rhsso-identity" on server "https://api.ocp4.example.com:6443".
...output omitted...Review the ocp-identity.yaml file that contains the definition of a OAuthClient custom resource.
You can find the file in the ~/DO313/labs/identity-review directory.
The redirectURIs field must be the same one you copied from RH-SSO.
Take note of the name and secret values from the custom resource.
Note that the redirectURI line has been split so that it displays correctly in the PDF guide.
kind: OAuthClient apiVersion: oauth.openshift.io/v1 metadata: name: ocp-identity secret: mysecret redirectURIs: - "https://sso.lab.example.com:8080/auth/realms/rhtraining/broker/openshift-v4/endpoint" grantMethod: prompt
Use the oc command to create the ocp-identity OAuthClient custom resource in the rhsso-identity namespace.
[student@workstation ~]$ oc create -f \
~/DO313/labs/identity-review/ocp-identity.yaml -n rhsso-identity
oauthclient.oauth.openshift.io/ocp-identity createdClose the terminal window.
Change to the RH-SSO Firefox tab.
Add a new identity provider of the type . Fill the identity provider parameters as follows. Leave the rest of the parameters unchanged.
| Parameter | Value |
|---|---|
| Display Name | OpenShift |
| Client ID | ocp-identity |
| Client Secret | mysecret |
| Base URL | https://api.ocp4.example.com:6443 |
Scroll down and click .
Test the Red Hat OpenShift user authentication in the finance-webapp application.
Use the Red Hat OpenShift user developer with developer as the password.
When prompted, fill in the parameters for the developer user just like the following table.
| Parameter | Value |
|---|---|
| Username | developer |
| developer@example.com | |
| First name | John |
| Last name | Doe |
Open a new private window in Firefox and navigate to the finance web application URL at http://localhost:8080/finance.
Click Show my access token.
Click .
When prompted, click htpasswd_provider and log in as the developer user with developer as the password.
Click .
The developer user consents to the Red Hat OpenShift identity provider to give the user information to RH-SSO.
Fill the parameters for the developer user in the previous table.
Click .
Close all the Firefox windows.
Close the application running in the terminal by pressing Ctrl+C.
Change to the /home/student directory.