Integrate third-party identity providers to secure RH-SSO applications.
Outcomes
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-broker
Procedure 4.2. Instructions
Log in as the admin user in the RH-SSO Admin Console.
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.
Verify the users for the rhtraining realm.
Click → .
Click .
Verify only alice is a user in the rhtraining realm.
Log in to your Red Hat OpenShift cluster as the admin user with the redhat password.
List the users.
Open the terminal application 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:6443
Login successful.
...output omitted...List the users on Red Hat OpenShift.
[student@workstation ~]$ oc get users
NAME UID FULL NAME IDENTITIES
admin ea966479-... htpasswd_provider:admin
developer 9bcedb9c-... htpasswd_provider:developerCreate the Red Hat OpenShift identity provider in RH-SSO.
Note that steps 4, 5, and 6 run in parallel. In step 4 you start creating the identity provider in RH-SSO to take note of the redirectURI parameter, but do not save it yet. In step 5 you create the OAuthClient custom resource by using the redirectURI from RH-SSO, and take note of the OAuthClient name and secret. Finally, in step 6 you finish the configuration for the identity provider in RH-SSO by using the name and secret from the OAuthClient.
Change to the RH-SSO Firefox tab.
Click → .
Select Openshift v4.
Copy the Redirect URI field.
Do not click yet.
Create the rhsso-identity project on Red Hat OpenShift and a OAuthClient custom resource.
Change to the terminal window where you logged in to Red Hat OpenShift.
Change to the ~/DO313/labs/identity-broker directory.
[student@workstation ~]$ cd ~/DO313/labs/identity-brokerCreate the rhsso-identity project.
[student@workstation identity-broker]$ oc new-project rhsso-identity
Now using project "rhsso-identity" on server "https://api.ocp4.example.com:6443".
...output omitted...Create the ocp-identity.yaml file as follows.
The redirectURIs field must be the same one that 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.
Do not add the line break in your YAML file.
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: promptUse the oc command to create the ocp-identity OAuthClient custom resource in the rhsso-identity namespace.
[student@workstation identity-broker]$ oc create -f \
ocp-identity.yaml -n rhsso-identity
oauthclient.oauth.openshift.io/ocp-identity createdComplete the identity provider fields on RH-SSO.
Change to the RH-SSO Firefox tab.
Fill the new identity provider parameters as follows.
| Parameter | Value |
|---|---|
| Display Name | OpenShift |
| Client ID | ocp-identity |
| Client Secret | mysecret |
| Base URL | https://api.ocp4.example.com:6443 |
Scroll down and click .
Run the finance-webapp application and test the Red Hat OpenShift user authentication.
Change to the terminal application and change to the ~/DO313/labs/identity-broker/finance-webapp directory.
[student@workstation identity-broker]$ cd \
~/DO313/labs/identity-broker/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-24 10:42:31,542 INFO [io.quarkus] (main)finance-webapp 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.14.2.Final) started in 1.940s. Listening on: http://0.0.0.0:8080 2023-01-24 10:42:31,544 INFO [io.quarkus] (main) Profile prod activated. 2023-01-24 10:42:31,544 INFO [io.quarkus] (main) Installed features: [cdi, oidc, oidc-client, oidc-token-propagation, qute, reactive-routes, rest-client, rest-client-jackson, resteasy, resteasy-qute, security, servlet, smallrye-context-propagation, smallrye-jwt, vertx]
Leave the terminal open.
Open a new Firefox tab 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 as follows.
| Parameter | Value |
|---|---|
| Username | developer |
| developer@example.com | |
| First name | John |
| Last name | Doe |
Click .
Verify the users for the rhtraining realm.
Change to the RH-SSO Firefox tab. Click → .
Verify developer is a user in the rhtraining realm.
Click the developer user ID.
Change to the tab.
Verify the developer user identity provider alias is openshift-v4.
Close all the Firefox windows.
Close the application running in the terminal by pressing Ctrl+C.
Change to the /home/student directory.
[student@workstation finance-webapp]$ cd
[student@workstation ~]$