Configure Red Hat Single Sign-On to authorize users and applications using the OpenID Connect (OIDC) protocol and the RBAC features of RH-SSO.
Outcomes
Create and manage roles in RH-SSO.
Create and manage composite roles in RH-SSO.
Create groups of users and assign roles by using the groups.
Identify the relationship between the OIDC tokens, and the RH-SSO roles.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that the RH-SSO realm is configured, and populated with users.
[student@workstation ~]$ lab start auth-authz
Procedure 3.2. Instructions
The finance-webapp and marketing-restful-api applications perform access control by using three RH-SSO realm roles.
The following table shows the relationship between the roles and the application endpoints.
Table 3.5. Roles and Endpoints
| Role | Application | Endpoint |
|---|---|---|
| marketing-user | marketing-restful-api |
http://localhost:3000/campaign/list
|
| finance-user | finance-webapp |
http://localhost:8080/finance/showinvoices
|
| finance-admin | finance-webapp |
http://localhost:8080/finance/addinvoices
|
The following tables show the users and groups already present in the rhtraining realm.
In this exercise you use the groups to grant different roles to users.
Run the finance-webapp application, and test the authorization.
Open the terminal application on the workstation machine and change to the ~/DO313/labs/auth-authz/finance-webapp directory.
[student@workstation ~]$ cd ~/DO313/labs/auth-authz/finance-webappFrom the terminal, compile and run the application.
[student@workstation finance-webapp]$ mvn quarkus:dev
...output omitted...
2022-12-15 07:41:26,210 INFO [io.quarkus] (Quarkus Main Thread) finance-webapp 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.14.2.Final) started in 3.001s. Listening on: http://localhost:8080
2022-12-15 07:41:26,211 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2022-12-15 07:41:26,211 INFO [io.quarkus] (Quarkus Main Thread) 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]
--
Tests paused
Press [r] to resume testing, [o] Toggle test output, [:] for the terminal, [h] for more options>The application can take some minutes downloading dependencies.
Leave the terminal open.
Open a new Firefox private window and navigate to the finance web application at http://localhost:8080/finance.
If you do not use a private window, the browser maintains the user identified, by using browser cookies, and the SSO session. You can also log out the user by finishing the sessions from the → in the RH-SSO Admin Console.
Click , and log in as the alice user, with alice as the password.
Click .
There is an authorization error, because the application requires the user to be in the finance-user role.
You can examine the piece of the source code of the finance-webapp application requiring authorization by opening the ~/DO313/labs/auth-authz/finance-webapp/src/main/java/com/example/ShowInvoices.java file.
Create the finance-user realm role.
Log in to the RHSSO 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.
In the left menu, navigate to the rhtraining realm, and click → .
Then, click .
Type finance-user in the Role Name field.
Then, click .
Add the finance-user realm role to the finance-users group.
From the RH-SSO Admin Console, click → .
Select group. Then, click .

Click the tab.
Then, select the finance-user role in the list of available roles, and click .

Add the bob user to the finance-users group.
From the RH-SSO Admin Console, click → .
Then click .
Click in the bob users row.
Then, navigate to the tab, click the finance-users group, and click .
Log in to the finance application as the bob user.
Open a new Firefox private window and navigate to the finance web application at http://localhost:8080/finance.
Click , and log in as the bob user, with bob as the password.
The bob user, in the finance-users group, can see the list of invoices because the group has the required role.
Click .
Then, fill the fields with random data, and click .
There is an authorization error, because the application requires the user to be in the finance-admin role.
You create this role later in this exercise.
Create the marketing-user role.
The last feature of the finance-webapp application is the request to the marketing-restful-api external application, to list the marketing campaigns.
You need that application running with its required role.
From the RH-SSO Admin Console, navigate to the realm, and then click → .
Then, click .
Type marketing-user in the Role Name field.
Then, click .
Add the marketing-user realm role to the marketing-users group.
From the RH-SSO Admin Console, click → .
Select the group. Then, click .
Navigate to the tab.
Then, select the marketing-user role in the list of available roles, and click .
Add the johndoe user to the marketing-users group.
From the RH-SSO Admin Console, navigate to → .
Then click .
Click in the johndoe users row.
Then, navigate to the tab, select the marketing-users group, and click .
Start the marketing-restful-api, and test access.
Open a new terminal application on the workstation machine, and change to the ~/DO313/labs/auth-authz/marketing-restful-api directory.
[student@workstation ~]$ cd ~/DO313/labs/auth-authz/marketing-restful-apiFrom the terminal, install dependencies and run the application.
[student@workstation ~]$ npm install && npm run start
...oupout omitted...
> marketing-restful-api@0.0.1 start /home/student/DO313/labs/auth-authz/marketing-restful-api
> node app.js
Started at port 3000The application can take some minutes downloading dependencies.
Leave the terminal open.
Open a new Firefox private window and navigate to the finance web application at http://localhost:8080/finance.
Click , and log in as the johndoe user, with johndoe as the password.
Click to access the list of campaigns.
The johndoe user, in the marketing-users group, can see the list of campaigns because the group has the required role.
Create the finance-admin composite role.
The users in the finance-admin role need to access all resources in the finance-webapp application, including the request to the external marketing-restful-api application.
From the RH-SSO Admin Console, navigate to the realm, and then click → .
Then, click .
Type finance-admin in the Role Name field.
Then, click .
Set to ON.
Then, in the Available Roles column select the finance-user, and marketing-user roles.
Click to move to the Associated Roles column.
Add the finance-admin realm role to the managers group.
From the RH-SSO Admin Console, click → .
Select group. Then, click .
Navigate to the tab.
Then, select the finance-admin role in the list of available roles, and click .
Add the alice user to the managers group.
From the RH-SSO Admin Console, navigate to → .
Then click .
Click in the alice users row.
Then, navigate to the tab, select the managers group, and click .
Test that the alice user has all the roles.
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.
Observe the claim inside the token with the list of roles.

Close all terminals and all the Firefox windows, and change to the /home/student directory.