Check Keycloak access to Red Hat OpenShift

Use Red Hat’s OpenShift 4.21 documentation to rehearse direct authentication through Keycloak and confirm a test user’s project access.

Before you start

  • Use a disposable OpenShift Container Platform 4.21 cluster. Verify a separate administrator kubeconfig and back up the current authentication settings before changing them. Review which resources Red Hat disables when direct authentication is enabled.
  • Use a test Keycloak realm and an account with read access to one test project. Red Hat documents separate clients for the web console and the OpenShift CLI. Follow its CLI-only settings if the console is disabled.

Data and access

Shared or checked
Keycloak verifies the identity, and OpenShift maps accepted token claims to its user and groups. OpenShift evaluates project access.
Check separately
Other identities and local administration have separate access paths. Check permissions in the intended project rather than assuming a cluster-wide grant.
  1. Confirm the test cluster and recovery path

    Check the OpenShift version and confirm that Red Hat’s direct authentication instructions apply. Open a separate administrator session with the installation kubeconfig or another independent administrator credential. Save the cluster’s current authentication settings and read Red Hat’s rollback instructions.

    Check. The independent administrator can reach the test cluster and has the existing configuration available.

  2. Configure and check the Keycloak clients

    Follow Red Hat’s example for the cluster’s console and CLI. Confirm the realm issuer URL, redirect addresses, client IDs, trust configuration and the claim OpenShift maps to the username. If the test realm requires a one-time code, enroll that account in Keycloak and check that the code works in a private browser.

    Check. The published client and issuer settings match the lab. If the realm requires a code, Keycloak prompts for it in the fresh session.

  3. Open a fresh session and verify project permissions

    Use Red Hat’s oc login instructions to open a fresh Keycloak session for the CLI. If your cluster has the web console enabled, repeat the sign-in there in a private browser. Check the CLI identity with oc whoami. Confirm the account can list pods in its test project and receives Forbidden for the same read in a second project without a grant. Use oc auth can-i create pods -n <test-project> to check the read-only assignment.

    Check. The CLI reports the expected test identity and the two project checks return different results.

Check your result

These steps follow Red Hat’s published OpenShift procedure. Run them in your own test cluster before changing production authentication. OpenShift applies the project grants. For the Red Hat Customer Portal and Hybrid Cloud Console, use the authenticator apps listed by Red Hat.

How to verify your setup

If you get stuck

The browser returns from Keycloak but OpenShift denies access

Check the client ID, callbacks, certificate trust and the username mapping. Compare oc whoami with the subject on the test project’s role binding. If the change blocks your test accounts, use the independent administrator context and Red Hat’s rollback procedure.

Report a problem with this guide

Explore all setup guides →