Bookmark this page

Lab: Install and Configure RH-SSO

  • Install and configure Red Hat Single Sign-On (RH-SSO) on Red Hat OpenShift, and use the RH-SSO user federation and role-base access control features to manage access for two different OpenID Connect secured applications.

Outcomes

  • Install Red Hat Single Sign-On on Red Hat OpenShift.

  • Deploy RH-SSO realm and clients by using custom resources.

  • Add Red Hat Identity Management (IdM) as a LDAP user federation provider in RH-SSO.

  • Synchronize users between RH-SSO and IdM.

  • Create and manage users, roles and groups in RH-SSO.

  • Use roles and groups to grant required user access for finance-webapp and marketing-restful-api applications.

If you did not reset your workstation and server machines at the end of the last chapter, then save any work you want to keep from earlier exercises on those machines, and reset them now.

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 compreview-rhsso

Specifications

  • Install the RH-SSO instance on Red Hat OpenShift by using the RH-SSO operator:

    • The Red Hat OpenShift web console URL is https://console-openshift-console.apps.ocp4.example.com.

    • Use the htpasswd_provider option to log in to the Red Hat OpenShift web console as the admin user with redhat as the password.

    • Create the rhsso namespace.

    • Install the RH-SSO operator on the rhsso namespace.

    • Use the keycloak external PostgreSQL database for the RH-SSO instance.

    • The external PostgreSQL database address is sso.lab.example.com and the port is 5432.

    • The external postgreSQL database, use the postgres username with postgres as the password.

    • You can modify the ~/DO313/labs/compreview-rhsso/secret.yaml to create the secret for the external database.

    • Create a do313-keycloak keycloak custom resource to install RH-SSO in the rhsso namespace.

  • Create a rhtraining realm by using the RH-SSO custom resource:

    • You can modify the ~/DO313/labs/compreview-rhsso/01rhtraining-realm.yaml file to create the rhtraining realm.

    • Create the custom resource in the rhsso namespace.

    • Modify the YAML file to enable user registration for the rhtraining realm.

    • Modify the YAML file to add a password policy to enhance password security by forcing all the users to have a password with a minimum length of 8 characters, and at least 1 special character.

  • Create and enable a client for the Quarkus finance-webapp application in the rhtraining realm by using the RH-SSO custom resource:

    • 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.

    • You can modify the ~/DO313/labs/compreview-rhsso/02finance-webapp-client.yaml file to create a client for the finance-webapp application.

    • Use the finance-webapp client ID for the client.

    • The finance-webapp allows only the OpenID Connect authorization code flow (standard flow) as a confidential client.

    • The root URL for the finance-webapp client is http://localhost:8080/finance.

    • The finance-webapp application is configured to use comp-secret as the client secret.

  • Create and enable a client for the marketing-restful-api application in the rhtraining realm by using the RH-SSO custom resource:

    • 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 the OpenID Connect authorization code flow as a bearer-only client. Thus, the application cannot initiate the login 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.

    • You can modify the ~/DO313/labs/compreview-rhsso/03marketing-restful-api-client.yaml file to create a client for the marketing-restful-api application.

    • Use the marketing-restful-api client ID for the client.

    • The marketing-restful-api client must allow only the OpenID Connect authorization code flow (standard flow) as a bearer-only client.

    • The root URL for the marketing-restful-api client is http://localhost:3000/campaign.

  • Create the LDAP IdM user federation provider to federate IdM by using the following parameters:

    ParameterValue
    Edit ModeREAD_ONLY
    VendorRed Hat Directory Server
    UUID LDAP attribute ipaUniqueID
    Connection URLldap://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
    • Use the RH-SSO Admin Console to create the user federation provider and import users with the correct first name.

    • Retrieve the RH-SSO admin credentials and URL from secret and router resources created by the do313-keycloak keycloak custom resource.

    • The IdM console URL is https://idm.ocp4.example.com.

    • Use the admin user with the r3dh4t12342022 password to log in to the IdM web console.

    • Verify that IdM has the eric and mike users and synchronize all users to RH-SSO.

    • In RH-SSO, verify that the First Name field for the users is not correctly imported.

    • Modify the User Federation mappers to correctly import the first name from IdM and synchronize all users again.

    • Verify that both users are correctly imported.

  • Use the RH-SSO Admin Console to create RH-SSO realm roles to access the finance-webapp and marketing-restful-api applications. The following table shows the relationship between the roles and applications:

    Table 6.1. Roles and Applications

    RoleApplication
    accountant finance-webapp
    marketing-analyst marketing-restful-api

  • Run the finance-webapp and marketing-restful-api applications:

    • The finance-webapp application is in the ~/DO313/labs/compreview-rhsso/finance-webapp directory.

    • The finance-webapp application is started with the mvn quarkus:dev command.

    • The marketing-restful-api application is in the ~/DO313/labs/compreview-rhsso/marketing-restful-api directory.

    • The marketing-restful-api application is started with the npm install && npm run start commands.

  • Register a new sally user from the finance-webapp client. The application is at http://localhost:8080/finance. Register the new sally user based on the following criteria:

    FieldValue
    First name Sally
    Last name Allen
    Email sally@example.com
    Username sally
    Password sallysally@
    Confirm Password sallysally@
  • Provide user access based on the following criteria:

    Table 6.2. User Access and Endpoints

    Users AccessRoleApplicationEndpoint
    All usersNone (only authenticated) finance-webapp http://localhost:8080/finance/showtokens
    Only eric and sally finance-webapp accountant http://localhost:8080/finance/showinvoices
    Only mike and sally marketing-restful-api marketing-analyst http://localhost:3000/campaign/list

    • Create the managers group.

    • Assign accountant and marketing-analyst roles to the managers group.

    • Add eric and mike to accountant and marketing-analyst roles, respectively.

    • Add the sally user to the managers group to give access to both applications.

    • Verify all users access.

    • The passwords for eric and mike users are ericeric@ and mikemike@, respectively.

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

[student@workstation ~]$ lab grade compreview-rhsso

Finish

As the student user on the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish compreview-rhsso

This concludes the section.

Revision: do313-7.6-bc10333