What you will have at the end
A Route called payments-api that only serves signed-in users of a Keycloak realm. A browser is sent to Keycloak to sign in, an API client sends a bearer token, and the backend receives the user’s identity in a header. On top of that, Keycloak’s own authorization decides which paths a user may call: refunds for the finance role, orders for everyone who is signed in. Every call, allowed or refused, is in Traffic Explorer, and the change that put the plugins on the Route is in the audit log with its secrets masked.
Prerequisites
- A Keycloak realm the G8 engine can reach. This article uses the realm
corpwith a confidential clientpayments-gateway(standard flow on, service account on, Authorization on) and two users:jane.millerwith the realm rolefinanceandsam.ortizwithout it. - An Environment in the G8 console with traffic logging turned on under Traffic Explorer › Settings and a Prometheus the Environment reads, so Analytics counts the Route.
- A backend. Here it is
payments-svc, a small service that answers under/payments/and prints the identity it finds in theX-Userinfoheader. - A role in the Environment that may manage Routes. The screenshots below were taken as
nora.becker.
Part one: OpenID Connect on the Route
The Route
Create the Upstream payments-backend with the node payments-svc:8080, then the Route payments-api with the path /payments/*, the methods GET and POST and the Upstream as its target. Call it once without any credentials: it answers 200, because nothing protects it yet.
Add the Plugin
Open the Route, switch to the Plugins tab and select Add plugin. Search for openid-connect in the catalog, select the tile and Configure. The form opens beside the Route with its settings in sections. Basics takes everything Keycloak needs:
- Discovery: the realm’s discovery document,
http://localhost:8190/realms/corp/.well-known/openid-configurationin this lab. The engine reads the endpoints and the signing keys from it. - Client ID and Client secret of the client
payments-gateway. The secret is stored on the engine and shown only to roles that manage the Route. - Bearer only stays off, so a browser without a token is sent to Keycloak instead of being refused.
- Scope:
openid profile email, so the user’s name and address come back in the identity token.

One setting sits outside Basics. Session › Secret signs the cookie the browser gets after it signs in; the form refuses to save without it while Bearer only is off. Select Add plugin: the Route is saved, the engine checks the configuration, and the audit log receives the change.
A second save follows. Behavior › Use jwks is off by default, and with it off a bearer token in the Authorization header is ignored: the API client is sent to the sign-in page like a browser. Switch it on and save again; the engine then verifies the token’s signature against the keys from the discovery document, and the audit log gets a second entry.
A browser signs in
Open http://localhost:9281/payments/me in a browser. The engine finds no session and answers 302 to Keycloak’s authorization endpoint with the client ID and the scope from the form.

After the sign-in, Keycloak sends the browser back to the Route, the engine exchanges the code for tokens, sets its session cookie and forwards the request. The backend answers with what it received:
{
"service": "payments-svc",
"path": "/payments/me",
"caller": {
"user": "jane.miller",
"name": "Jane Miller",
"email": "jane.miller@corp.example"
},
"headers": { "authorization": null, "x-userinfo": "present" }
}
The backend never saw a password or a token. It read the X-Userinfo header, which the Plugin adds with the claims from Keycloak, base64-encoded.
An API client sends a token
An API client gets a token from Keycloak’s token endpoint and sends it as a bearer token. The same Route answers 200 and the backend sees the same identity:
curl -H "Authorization: Bearer $TOKEN" http://localhost:9281/payments/me
A token the engine cannot verify is refused at the gateway, before the backend is called:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="invalid_token", error_description="invalid jwt: invalid jwt string"
Part two: Keycloak authorization on the same Route
openid-connect answers who the caller is. Which paths that caller may use is a separate question, and Keycloak can answer it too: in the client’s Authorization tab, the resource refunds carries the URIs /payments/refunds/* and a permission that needs the role finance; the resource orders carries /payments/orders/* and a permission any signed-in user passes.
Add a second Plugin to the Route, authz-keycloak. Its Basics are the client ID, the client secret and Discovery, which here is the realm’s UMA 2 document, http://localhost:8190/realms/corp/.well-known/uma2-configuration. Under Behavior, switch Resolve the resources from the path on. The form notes what that means: the resources are looked up from the request path at every request, and the Permissions list above is not read at all.

The Plugin runs after openid-connect (priority 2000 against 2599), so it always sees a verified token. It asks Keycloak for a decision on the path and keeps the answer in its cache. The result, measured with the two users’ tokens:
jane.miller GET /payments/refunds/rf-2041 200
jane.miller GET /payments/orders/ord-10421 200
sam.ortiz GET /payments/refunds/rf-2041 403 {"error":"access_denied","error_description":"not_authorized"}
sam.ortiz GET /payments/orders/ord-10421 200
jane.miller GET /payments/me 403
The last line is worth a look. Under the default Policy enforcement mode ENFORCING, a path no resource covers is refused for everyone, Jane included. Register every path the Route serves as a resource in Keycloak, or put the paths that need no authorization on a Route of their own.
What Traffic Explorer shows
Every call above is a request record. Open Observe › Traffic Explorer and the list carries the 200s next to the 401 and the 403s. The Upstream node column says who answered: the backend’s node for a 200, shown as the address the engine resolved payments-svc:8080 to, and gateway for a refusal the engine made itself.

Open a record and switch to its Request tab: the headers are there as the gateway received them. The authorization header reads ********, masked by the gateway before the record was stored, because it is on the Environment’s default mask list. Two headers were not, at first: openid-connect adds x-access-token and x-userinfo to the request it forwards, both carrying the signed-in user’s claims, and the first records of this session stored them in clear. Add them under Traffic Explorer › Settings › Masking › Request headers and save; every record written from then on masks them, as the one below does.

What the audit log keeps
Adding the Plugin was a change to the Route, so the audit log has an entry: who, when, which Route and the configuration before and after. The client secret and the session secret appear as •••• on both sides, and the record names the masked paths that changed. Nobody reads a secret from the audit log, not even the person who typed it.

The Route’s Analytics tab counts the same refusals by code and draws the audit entries as markers on the request chart; Who changed what shows those markers.
Side by side with other identity methods
A Route can admit more than one kind of caller. The multi-auth Plugin takes a list of at least two authentication Plugins and tries them in order until one admits the request; the configurations G8 ships combine key-auth, basic-auth, jwt-auth and hmac-auth. openid-connect keeps its own session and stays a Plugin of its own.
What to do next
- Switch Set access token header off in the
openid-connectform if the backend does not need the token itself; the identity inX-Userinfois usually enough. - Copy the Route to the production Environment when it works. G8 shows what the copy changes before anything is written, and the copy is an audit entry: Change control and audit.
- The same Plugin for a machine caller with a bearer token, and
jwt-authbeside it: OAuth 2.0 access tokens at the gateway. - Read how the Route’s rules apply to AI agents in OpenAPI to MCP, and how the gateway’s identity options fit together on API security.