Keycloak Step-up Authentication
You set up keycloak step up authentication by tying trust levels to specific login steps. When an app asks for a higher level, Keycloak forces a fresh factor check. Teams use this flow to let staff log in once with a simple password. They only prompt for a hardware token when someone opens a sensitive admin page. If you skip this setup, every user gets full rights right at login. Overly broad roles mean one stolen session cookie can expose your whole system. How keycloak step up authentication
Step-Up Authentication + Keycloak: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up keycloak step up authentication by tying trust levels to specific login steps. When an app asks for a higher level, Keycloak forces a fresh factor check. Teams use this flow to let staff log in once with a simple password. They only prompt for a hardware token when someone opens a sensitive admin page. If you skip this setup, every user gets full rights right at login. Overly broad roles mean one stolen session cookie can expose your whole system.
How keycloak step up authentication works in practice
Keycloak relies on OpenID Connect trust strings to track how a user logged in. Admins build a browser login flow that splits steps into numbered levels. Level one might check a username and a password from a directory. Level two might ask for a one-time code from a mobile phone app. Level three can require a physical security key touch before granting a token.
Your client app starts this upgrade when a user clicks a protected action. The app sends a new login request to Keycloak with a specific level claim. Keycloak reads the active session and compares the current level to the requested one. If the user only passed level one, Keycloak shows the level two prompt. The user does not need to type their password a second time. Once they pass the new check, Keycloak issues a fresh token with the updated claim.
Planning login levels and session lifespans
Clear level maps stop login fatigue across your engineering team. Put everyday read views at your base level so staff can work fast. Reserve your highest trust level for production settings, billing panels, and user role changes. You also need to set short lifespans on upgraded tokens. If a high-level token lasts all day, the step-up prompt loses its value.
Test how your client apps handle failed or canceled prompts. A user might lose their hardware key or close the browser tab mid-check. The app must catch the error response from Keycloak and keep the current session intact. Good error handling drops the user back to their normal view with a clear message.
Step-Up Authentication + Keycloak: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What identity step-up solves and where gaps remain
Identity step-up works well for web apps that understand OpenID Connect claims. It stops attackers who steal a basic session from opening an admin dashboard. It also keeps login prompts quiet until a user actually needs extra power.
Still, Keycloak only checks who logs in at the start of a web flow. It cannot see what happens inside a database session or a server shell. Once an engineer passes a step-up check to reach a database, the identity provider steps aside. Keycloak cannot tell a safe table read apart from a dangerous drop command. It also cannot mask sensitive fields like emails, phone numbers, card numbers, or national IDs in query results. Teams that need command-level control must pair identity checks with runtime session controls.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Does step-up login require users to type their password again?
No, Keycloak remembers the first login step from the active browser session. It only shows the missing factor prompt needed to reach the higher level.
Can legacy apps use Keycloak step-up flows?
The app must support OpenID Connect claims and know how to request specific trust levels. Older apps or direct database clients cannot trigger these prompts on their own.
What happens to the old token after a user steps up?
Keycloak updates the user session state and sends back a brand new token. This new token holds the higher level claim so the app can check it.
Related guides
In this post