Keycloak Federated Client Authentication

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up keycloak federated client authentication by linking an external identity provider to your realm. Instead of storing static secrets, your client sends a signed token from a trusted issuer. Teams use this approach so services can log in without saving passwords in files. Still, teams often grant broad roles to these federated identities during setup. When a service holds wide permissions, one bad script can drop tables or read private records. How keycloak federated client authenticat

Keycloak + Client-Initiated Backchannel Authentication (CIBA): the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up keycloak federated client authentication by linking an external identity provider to your realm. Instead of storing static secrets, your client sends a signed token from a trusted issuer. Teams use this approach so services can log in without saving passwords in files. Still, teams often grant broad roles to these federated identities during setup. When a service holds wide permissions, one bad script can drop tables or read private records.

How keycloak federated client authentication works

In a standard flow, an app proves who it is with a secret string. Someone has to create that secret, copy it, and rotate it on a schedule. With federated trust, you skip the shared secret and rely on cryptographic keys instead. Your workload gets a signed token from its host platform or an external identity provider. Then the workload sends that token to Keycloak when it asks for an access token.

Keycloak checks the token against the public keys of the external issuer. It also checks that the issuer name and subject match the client rules you set. If every check passes, Keycloak trusts the client and returns a new token. This flow works well for cloud workloads, build runners, and apps that run across regions. You do not need to store static passwords inside your code repos or build tools.

Choosing and mapping external token issuers

Before you turn on federated login, you must pick a trusted token issuer. Many teams use their cloud provider, a container platform, or a build system as the issuer. Each of these platforms can issue short-lived tokens to workloads that run on them. You register the discovery endpoint or public key URL of that issuer inside your realm. This step tells Keycloak where to fetch the keys needed to check incoming signatures.

Next, you bind a specific client profile to the exact claims inside the external token. You should match both the issuer URL and the unique subject name of the workload. If you only check the issuer URL, any app on that platform could log in. Tight claim matching stops one test service from acting like a production service. Good claim rules keep your apps in their own lanes during the login step.

Keycloak + Client-Initiated Backchannel Authentication (CIBA): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What federated client login solves and what it misses

Federated trust removes the pain of leaked client secrets and missed key rotations. Attackers do not receive unmasked a static password from a config file if no password exists. Your security team also gains a single place to turn off client trust when needed. If you remove the issuer link, the client can no longer get new tokens.

Yet client login only decides who can open the door at the start. Once a service or engineer gets a token, Keycloak steps out of the way. It cannot see which database queries run or which commands execute inside a session. A valid client with a broad role can still run a bad update by mistake. It can also pull raw emails, phone numbers, card numbers, or national IDs from tables. Identity checks alone do not filter sensitive fields or block risky commands in flight.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Why use federated tokens instead of client secrets in Keycloak?

Client secrets can leak in logs, code repos, or build scripts if someone makes a mistake. Federated tokens come from a trusted issuer at runtime and expire after a short window.

What happens if the external identity provider key changes?

When you link a discovery URL, Keycloak fetches the new public keys when they rotate. If you paste a static public key by hand, you must update it yourself before rotation.

Does federated client login restrict what queries a service can run?

No, it only checks the identity of the client and issues a token for the session. It does not inspect SQL queries, shell commands, or API payloads after login completes.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.