Tested with Keycloak 26.8.2 in Docker on macOS.
Alice walks up to a self-service kiosk at her bank branch and types her username. Nothing else. Her phone buzzes: "Kiosk App wants to sign in as alice. Code: KIOSK-4821." The kiosk shows the same code. She taps Approve, and the kiosk signs her in. She never typed a password on a shared screen.
That's CIBA, OpenID Connect Client-Initiated Backchannel Authentication. The app that wants the tokens never shows a login page. It asks the identity provider to authenticate a named user on another device, and waits. The same pattern fits a call-centre tool acting on a caller's account, a smart TV, or an AI agent that needs a person's go-ahead.
CIBA is a supported Keycloak feature (ciba), enabled by default since Keycloak 13.0. The catch is the part it leaves out: Keycloak doesn't know how to reach the user's phone. You have to build that. This post builds it as a small Keycloak extension and runs the whole flow on a laptop with a demo repo.
How CIBA works
CIBA has three parties:
- Consumption device (CD): the app that wants tokens. Here, a kiosk.
- Authentication device (AD): where the user says yes. Here, a phone.
- OpenID Provider: Keycloak, in the middle.
The demo uses poll mode: the kiosk keeps asking until there's an answer. (Keycloak also supports ping mode, where it notifies the client when the tokens are ready. It doesn't support the spec's push mode.) Step by step:
- The kiosk calls Keycloak's backchannel authentication endpoint with its client credentials and
login_hint=alice. - Keycloak passes the request to an authentication channel, which delivers it to Alice's phone. Once the channel accepts it, Keycloak returns an
auth_req_idto the kiosk, without waiting for Alice's approval. (That's also why an unreachable channel fails the initial request.) - The kiosk polls the token endpoint with the
auth_req_id. Until Alice answers, it getsauthorization_pending. - Alice approves on the phone. The phone tells Keycloak through a callback endpoint.
- The next poll returns Alice's tokens.
The binding_message is a short code shown on both screens. The spec calls it a visual way to correlate the two: the matching code helps Alice tie the phone prompt to the request she just started at the kiosk. The demo hard-codes KIOSK-4821 so the outputs are reproducible; a real kiosk should generate a fresh, unpredictable code for each request.
What Keycloak gives you, and what it doesn't
| Keycloak provides | You provide |
|---|---|
Backchannel endpoint: /realms/{realm}/protocol/openid-connect/ext/ciba/auth | Something that gets the request to the user's device |
Token endpoint support for urn:openid:params:grant-type:ciba | The app on that device, which authenticates the user and says yes or no |
Callback endpoint: .../ext/ciba/auth/callback | |
| A realm CIBA policy and a per-client OIDC CIBA Grant switch |
The CIBA spec doesn't say how the user is reached, so Keycloak hands that to an "authentication entity" under the administrator's control (Server Admin guide, CIBA), through the ciba-auth-channel SPI (Service Provider Interface, Keycloak's plug-in mechanism). The built-in ciba-http-auth-channel POSTs the request as JSON to a URL you configure and expects exactly HTTP 201; your service later calls the callback endpoint with the bearer token it received. A custom channel is worth writing when you want your own transport (a push service, a queue, an existing notification API) or payload.
Heads-up:
ciba-auth-channelis an internal SPI. Keycloak 26.8.2 warns at startup that it "may change without notice". Pin your Keycloak version and re-test the extension on every upgrade.
Try it on your laptop
You need Git, Docker with Compose, Bash, curl and python3 (the scripts use it to read JSON). The extension is compiled inside Docker, so no local Java or Maven.
git clone https://github.com/Anoopgopi/keycloak-ciba-auth-channel-demo.git cd keycloak-ciba-auth-channel-demo ./scripts/run-all.sh run-all.sh builds Keycloak 26.8.2 with the extension, starts it next to a pretend phone (a small web page standing in for Alice's phone; it demonstrates delivery and approval only, and does not authenticate the user or verify device ownership), creates the realm and runs the flow. The first run takes a few minutes while Docker builds the image. When the script prints Open http://localhost:3300 (the phone) and tap Approve, do exactly that in a browser. The script then prints the tokens and runs the edge cases from "What can go wrong" below; those answer on the phone's behalf, so leave the phone page alone until the script prints Done. The rest of this post walks through what each piece does. All output below is from Keycloak 26.8.2 and the demo code base.
Step 1: the extension
A channel is two classes and a service file. The provider has one job: deliver the request and return true if the device has it. Shortened (the full file is in the repo):
public class DevicePushChannelProvider implements AuthenticationChannelProvider { @Override public boolean requestAuthentication(CIBAAuthenticationRequest request, String username) { ClientModel client = request.getClient(); String issuer = request.getIssuer(); Map<String, Object> push = new LinkedHashMap<>(); push.put("username", username); push.put("client_name", client.getName()); push.put("binding_message", request.getBindingMessage()); push.put("scope", request.getScope()); push.put("expires_at", request.getExp()); push.put("callback_url", issuer + "/protocol/openid-connect/ext/ciba/auth/callback"); push.put("callback_token", callbackToken(request, client)); int status = SimpleHttp.create(session).doPost(deviceUrl).json(push).asStatus(); return status >= 200 && status < 300; } } callbackToken() builds the same token Keycloak's built-in channel uses: signed by the realm, tied to this one request, and expiring with it. It's the phone's only proof that it may answer.
The factory registers the provider as demo-device-push and reads one setting, deviceUrl. A file at META-INF/services/org.keycloak.protocol.oidc.grants.ciba.channel.AuthenticationChannelProviderFactory names the factory class.
The repo's Dockerfile compiles the two classes against the jars inside the Keycloak 26.8.2 image itself (no Maven needed), so the extension always matches the version it runs on, and copies the jar into /opt/keycloak/providers/.
Step 2: turn it on
Two server options select the channel and configure it (the demo uses start-dev over plain HTTP; in production you'd use start with TLS, a real hostname and a database):
command: - start-dev # dev mode: local demo only - --hostname=http://localhost:8080 - --spi-ciba-auth-channel--provider=demo-device-push - --spi-ciba-auth-channel--demo-device-push--device-url=http://phone:3000/push (A port note: inside the Docker network the phone listens on 3000, which is what device-url points at; Compose publishes it on your machine as 3300, the page you open.)
Don't skip the --hostname line. Keycloak checks the callback token against the realm issuer of the callback request. Inside Docker the phone reaches Keycloak as http://keycloak:8080, while the kiosk uses http://localhost:8080, so without a fixed hostname the two issuers differ. In testing, the phone's callback came back 403 invalid_token; with --hostname=http://localhost:8080 the same callback returned 200.
Step 3: the realm and the client
setup-realm.sh creates realm demo with a CIBA policy (in the Admin Console: Authentication → Policies → CIBA Policy):
| Setting | Value | Meaning |
|---|---|---|
| Backchannel Token Delivery Mode | poll | The kiosk polls the token endpoint |
| Expires In | 120 | Seconds the request stays valid |
| Interval | 5 | Minimum seconds between polls |
| Authentication Requested User Hint | login_hint | The kiosk names the user with login_hint |
It adds a user alice and a client kiosk-app: confidential, with only the OIDC CIBA Grant switched on (oidc.ciba.grant.enabled), no browser flows.
Step 4: the kiosk asks
ciba-login.sh runs this step and the next; the commands are shown so you can follow what it does.
curl -s http://localhost:8080/realms/demo/protocol/openid-connect/ext/ciba/auth \ -u kiosk-app:kiosk-app-local-demo-secret \ -d scope=openid -d login_hint=alice -d binding_message=KIOSK-4821 {"auth_req_id": "eyJhbGciOiJkaXIiLCJlbmMi...", "expires_in": 120, "interval": 5} At the same moment the phone receives the push:
The scope line shows openid plus the default scopes Keycloak adds for this client.
Step 5: Alice approves
The kiosk polls the token endpoint every 5 seconds (the script saved Step 4's auth_req_id as $AUTH_REQ_ID):
curl -s http://localhost:8080/realms/demo/protocol/openid-connect/token \ -u kiosk-app:kiosk-app-local-demo-secret \ -d grant_type=urn:openid:params:grant-type:ciba -d auth_req_id="$AUTH_REQ_ID" authorization_pending authorization_pending Alice taps Approve, and the phone POSTs {"status": "SUCCEED"} to the callback endpoint with its callback token as the bearer. Keycloak answers 200, and the next poll returns a full token response: access token, ID token, refresh token and a session. The access token's claims:
{ "iss": "http://localhost:8080/realms/demo", "sub": "38209fd3-…", "azp": "kiosk-app", "preferred_username": "alice", "scope": "openid email profile", "sid": "LWCsogd1…" } Alice is signed in to the kiosk, and she never typed a password into it. Keycloak took the phone's word for it, which is why the next two sections matter.
What can go wrong
checks.sh automates most of the cases below; the offline-phone case, the full two-minute expiry and the 15-second callback in the note were separate runs against the same build. Every result is from Keycloak 26.8.2:
| Case | What happened |
|---|---|
Alice taps Deny (UNAUTHORIZED) | Next poll: access_denied |
| Kiosk polls twice in a row | Second poll: slow_down ("too early to access") |
| Nobody answers | authorization_pending until the 120 s run out, then expired_token |
| Phone replays its callback after approving | 403 invalid_token |
Kiosk reuses the auth_req_id after getting tokens | invalid_grant |
| Callback with a made-up token | 403 |
| Phone is offline | Backchannel request fails with 503, server_error |
binding_message with a space | invalid_binding_message (max 50 chars, letters, digits and -._+/!?#) |
Unknown user in login_hint | invalid_request, invalid_user |
One result is easy to misread: with requested_expiry=10, Keycloak still answered expires_in: 120. Only the phone's window shrank (its callback after 15 seconds got 403); the kiosk kept polling until the realm's 120 seconds ran out. And slow_down carries an obligation: the spec says the client must add at least five seconds to its polling interval for this and all later requests, not just retry.
Security notes
- The client picks the user. Any client with the CIBA grant can trigger a push to any username it knows. That's the main way CIBA gets abused: unwanted prompts, again and again, until a tired user taps Approve. Enable the grant only for trusted clients, rate-limit them, and require a binding message with the built-in
secure-ciba-sessionclient policy executor. - Usernames can be probed. An unknown
login_hintreturnsinvalid_user, a known one returns anauth_req_id, so anyone with a CIBA client's credentials can tell which usernames exist. - The device is the authenticator. Keycloak issues tokens because the device said
SUCCEED, so the device app must authenticate the user (unlock, biometrics, a PIN) before answering. The demo phone does none of that. - The callback token is a bearer token. Anyone holding it can approve that one request until it expires. Keep Expires In short and deliver the token only over TLS.
- Use confidential clients. On Keycloak 26.8.2, a public client with the CIBA grant was accepted at both endpoints without a secret and received tokens. The spec requires client authentication, and the Keycloak 27.0 upgrade notes list the fix as CVE-2026-109082 (changes in 27.0.0).
- Regulated deployments. For the FAPI-CIBA profile, Keycloak ships the
secure-ciba-signed-authn-reqandsecure-ciba-req-sig-algorithmexecutors.
From demo to production
The pretend phone takes every request for every user, and the push carries the callback token in its body. A real channel routes each request to the user's own enrolled device, sends only a wake-up signal through a push service (APNs, FCM), and lets the app fetch the request details and callback token from your backend over TLS after the user unlocks it.
Where to start
- Decide what your authentication device is: an existing mobile app, a push service, a messaging channel. That decides whether the built-in HTTP channel is enough or you need your own.
- Turn on the CIBA grant only on confidential clients that need it, with a CIBA policy in poll mode and a short expiry.
- If you write a channel, keep it small, and fix the hostname so the token issuer is the same for every caller.
- Run the demo repo, then swap the pretend phone for your real device app.
References
- OpenID Connect Client-Initiated Backchannel Authentication Core 1.0: https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0.html
- Keycloak Server Admin guide, CIBA grant (source): https://github.com/keycloak/keycloak/blob/main/docs/documentation/server_admin/topics/sso-protocols/con-oidc-auth-flows.adoc
- Keycloak 26.8.2 source, CIBA package: https://github.com/keycloak/keycloak/tree/26.8.2/services/src/main/java/org/keycloak/protocol/oidc/grants/ciba
- Keycloak 27.0.0 upgrade notes, "CIBA requires client authentication": https://github.com/keycloak/keycloak/blob/main/docs/documentation/upgrading/topics/changes/changes-27_0_0.adoc
- Demo repo: https://github.com/Anoopgopi/keycloak-ciba-auth-channel-demo
Anoop Gopi is a senior technology leader and digital identity expert specializing in IAM, cybersecurity and cloud architecture. Views are his own.



