Configure Red Hat Single Sign-On to authenticate users and applications using the OpenID Connect (OIDC) protocol.
Outcomes
Configure RH-SSO clients for Open ID Connect (OIDC) Authorization Code Flow, with confidential and public clients.
Configure RH-SSO clients for the OAuth2 Client Credentials Grant.
Describe the requests involved in OIDC Authorization Code Flow, with confidential and public clients.
Describe the content of different OIDC tokens.
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 auth-oidc
Procedure 3.1. Instructions
In this exercise you configure three RH-SSO clients for authentication of three different types of applications:
The finance-webapp application is a server-side web application that uses the OpenID Connect authorization code flow as a confidential client to authenticate the application users.
The application uses the Java Quarkus framework and the Quarkus integration with OpenID Connect identity servers.
The finance-webapp application calls an external endpoint in the marketing-restful-api application.
The marketing-restful-api application is a Node.js back end service which serves REST endpoints.
It uses an RH-SSO service account with a confidential secret, which enables the client credentials grant from OAuth2.
Thus, the application cannot initiate the log in process, but RH-SSO can generate the access token for this client.
The marketing-restful-api application uses the Node.js adapter from RH-SSO to integrate with the authentication server.
The marketing-html5 is a single-page application (SPA) developed with HTML5 and JavaScript, which runs in a browser.
It uses the OpenID Connect authorization code flow as a public client.
The application uses the JavaScript adapter from RH-SSO to integrate with the authentication server.
The marketing-html5 application calls an external endpoint in the marketing-restful-api application.
Log in to RH-SSO Admin Console.
On the workstation machine, use Firefox to navigate to the Red Hat Single Sign-On web UI URL at https://sso.lab.example.com:8080.
Click .
Log in as the admin user with redhat as the password.
Create a client for the Quarkus finance-webapp in the rhtraining realm.
Navigate to realm, and then click → . Then, click .
Create the client based on the following criteria.
Table 3.2. Finance web application client creation
| Field | Value |
|---|---|
Client ID
|
finance-webapp
|
Client Protocol
|
openid-connect
|
Root URL
|
http://localhost:8080/finance
|
Click .
On the page that opens, set Direct Access Grants Enabled to OFF, and select confidential in the Access Type field.

Scroll down and click .
Navigate to the tab, and take note of the secret value.

Configure, run, and test the authentication for the finance-webapp application.
Open the terminal application on the workstation machine and change to the ~/DO313/labs/auth-oidc/finance-webapp directory.
[student@workstation ~]$ cd ~/DO313/labs/auth-oidc/finance-webappModify the finance-webapp/src/main/resources/application.properties configuration file, to include the client secret you noted in the previous step.
quarkus.oidc.auth-server-url=https://sso.lab.example.com:8080/auth/realms/rhtraining
quarkus.oidc.application-type=web-app
#For web-app type applications, Quarkus needs to read the roles from access token, instead of the idToken:
quarkus.oidc.roles.source=accesstoken
quarkus.oidc.client-id=finance-webapp
quarkus.oidc.credentials.secret=wRaGhUsdJKIe8PL0ShboprtyLDgzPd5H
...output omitted...From the terminal, compile and run the application.
[student@workstation finance-webapp]$ mvn install && \
java -jar target/quarkus-app/quarkus-run.jar
...output omitted...
022-11-17 13:22:04,304 INFO [io.quarkus] (main) finance-webapp 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.14.0.Final) started in 1.230s. Listening on: http://0.0.0.0:8080
2022-11-17 13:22:04,310 INFO [io.quarkus] (main) Profile prod activated.
2022-11-17 13:22:04,310 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 new Firefox private window and navigate to the finance web application at http://localhost:8080/finance.
Click .
Try to log in with the admin user, with redhat as the password.
The authentication fails because the admin user is not present in the rhtraining realm.
Close the Firefox private window.
Create the alice user, and test the access to the finance web application.
Use Firefox to log in again to the RH-SSO Admin Console at https://sso.lab.example.com:8080.
Click → . Then, click .
Create the user based on the following criteria. Leave the other fields empty.
| Field | Value |
|---|---|
Username
|
alice
|
Email
|
alice@example.com
|
First Name
|
Alice
|
Last Name
|
in Chains
|
User enabled
|
ON
|
Email verified
|
ON
|
Click .
Navigate to the tab of the alice user to set the password.
Fill the Password, and Password Confirmation fields using alice as the password.
Set the to OFF.
Then, click and confirm the change.

Open a new Firefox private window and navigate to the finance web application at http://localhost:8080/finance.
Click , and log in as the alice user, with alice as the password.
The authentication now works, because you are using a user that belongs to the rhtraining realm.
The application shows the access token, and all its claims.
You can see the RH-SSO standard OIDC Authorization Code activities in the log showed in the terminal for the finance-webapp application.
Close the Firefox private window.
Observe the requests to the RH-SSO server from the browser.
Open a new Firefox private window and press the F12 key to show the Firefox developer tools. Click to show Firefox's network monitor.

Navigate to the finance web application at http://localhost:8080/finance.
There are no requests to the sso.lab.example.com:8080 server.
Click .
Scroll up over the list of requests, and observe the first request to the sso.lab.example.com:8080 server.

Log in as the alice user with alice as the password.
Observe the requests to the sso.lab.example.com:8080 server.

The user browser never receives any token, nor requests directly to the token OIDC endpoint.
Close the Firefox private window.
Create a client for the marketing-restful-api services applications.
Navigate to the realm, and then click → . Then, click .
Create the client based on the following criteria.
Table 3.3. Marketing Restful API client creation
| Field | Value |
|---|---|
Client ID
|
marketing-restful-api
|
Client Protocol
|
openid-connect
|
Root URL
|
http://localhost:3000/campaign
|
Click .
On the page that opens, select confidential in the Access Type field, and set the Direct Access Grants Enabled and Standard Flow Enabled fields to OFF.
Select the Service Accounts Enabled field.

Scroll down and click .
Configure, run, and test the authentication for the marketing-restful-api services applications.
Open a new terminal application on the workstation machine and change to the ~/DO313/labs/auth-oidc/marketing-restful-api directory.
[student@workstation ~]$ cd ~/DO313/labs/auth-oidc/marketing-restful-apiRun the Node application.
[student@workstation marketing-restful-api]$ npm run start
> marketing-restful-api@0.0.1 start /home/student/DO313/labs/auth-oidc/marketing-restful-api
> node app.js
Started at port 3000Leave the terminal open.
Open a new Firefox private window and navigate to the finance web application at http://localhost:8080/finance.
Click , to log in as the alice user, with alice as the password.
Then, click .
You can see the list of marketing campaigns because the finance-webapp application uses the access token to call to the external endpoint present in the marketing-restful-api application.
You can see the HTTP request, with the access token, in the log showed in the terminal for the marketing-restful-api application.

Output from the marketing-restful-api application.
Close the Firefox private window.
Create a client for the marketing-html5 single page application.
From the RH-SSO Admin Console, navigate to the realm, and then click → .
Then, click .
Create the client based on the following criteria.
Table 3.4. Marketing SPA application client creation
| Field | Value |
|---|---|
Client ID
|
marketing-html5
|
Client Protocol
|
openid-connect
|
Root URL
|
http://localhost:8081/marketing-html5
|
Click .
On the page that opens, set Direct Access Grants Enabled to OFF, and leave public in the Access Type field.
Scroll down and click .
Configure, run, and test the authentication for the marketing-html5 single page application.
Open a new terminal application on the workstation machine and change to the ~/DO313/labs/auth-oidc/marketing-html5 directory.
[student@workstation ~]$ cd ~/DO313/labs/auth-oidc/marketing-html5Run the Node application that wraps the single-page application.
[student@workstation marketing-restful-api]$ npm run start
> marketing-html5@0.0.1 start /home/student/DO313/labs/auth-oidc/marketing-html5
> node app.js
marketing-html5 listening on port 8081Leave the terminal open.
Access the marketing-html5 application and examine the requests.
Open a new Firefox regular window and press the F12 key to show the Firefox developer tools.
Click to show Firefox's network monitor.
Navigate to the marketing single-page application at http://localhost:8081/marketing-html5.
Observe the requests to the sso.lab.example.com:8080 server from a hidden HTML iframe, even when there are still no authenticated requests.
The RH-SSO JavaScript adapter maintains the status by using a hidden HTML iframe in the JavaScript application.
Click to log in as the alice user, with alice as the password.
Then, click and observe the request to the OIDC token endpoint. With a public client application all the tokens reach the user device.

Close all the Firefox windows.
Close all the applications running in terminals by pressing Ctrl+C.