Keycloak Flows Explained
To understand keycloak flows explained, look at them as ordered steps that check user logins. Each flow groups smaller tasks that verify a user before granting a token. Teams often copy a default login flow and assign broad roles to get apps running fast. When those roles stay too wide, any logged-in user can run risky actions inside backend systems. Keycloak flows explained at an architectural level A flow is a container that holds every step needed to log in a user. When a person opens an a
Keycloak: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
To understand keycloak flows explained, look at them as ordered steps that check user logins. Each flow groups smaller tasks that verify a user before granting a token. Teams often copy a default login flow and assign broad roles to get apps running fast. When those roles stay too wide, any logged-in user can run risky actions inside backend systems.
Keycloak flows explained at an architectural level
A flow is a container that holds every step needed to log in a user. When a person opens an app, the identity server starts the assigned flow for that client. The server runs each step in exact order from top to bottom. One step might check a password, while the next step asks for a one-time code.
Admins set rules on each step to tell the server how to move forward. A step can be mandatory, optional, or grouped with other choices. If a mandatory step fails, the server stops the flow and blocks the login right away. If all required steps pass, the server builds a token and sends the user back to the app.
Different login paths use different built-in flows to handle specific tasks. Browser logins use a flow that redirects people to web forms and checks browser cookies. Direct API calls use a simpler flow that checks client secrets without showing any web pages. Registration, password resets, and first-time social logins each run their own separate flows too.
How teams build custom login sequences
Teams rarely edit the built-in flows directly because bad changes can lock everyone out. Instead, admins copy an existing flow and change the steps inside the new version. They might add a step that checks if a user belongs to a specific group. They can also add a step that forces new users to accept terms of service.
Sub-flows let teams nest smaller groups of steps inside a main login path. For example, a team can create a sub-flow that offers two ways to pass a second check. The user can either enter a phone code or tap a hardware security key. If either choice succeeds, the whole sub-flow passes and the main login moves on.
Once the custom flow is ready, the admin binds it to a specific client app. That way, high-risk admin tools can demand strict multi-step checks during login. At the same time, low-risk internal dashboards can keep using a fast single-step login flow.
Keycloak: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What login flows solve and where gaps remain
Login flows do a great job of proving who a person is before granting a token. They let security teams enforce multi-factor checks, password rules, and group checks in one place. When a user passes the flow, the app knows the identity token is valid and trusted.
Still, a login flow only runs at the front door when a session starts. Once the identity server hands out a token, its job in the workflow is done. The flow cannot see what queries or commands the user runs inside a database or server later. It also cannot mask sensitive fields like emails, phone numbers, or card numbers in query results.
If an engineer logs in with a valid token, they get whatever role the token carries. A broad role lets them run destructive commands or read thousands of customer rows at once. Login flows check identity at the start, but they do not control live actions 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
What is the difference between a main flow and a sub-flow?
A main flow controls the entire login journey from the first request to the final token. A sub-flow is a nested group of steps inside that main path that handles one complex check.
Can different apps in the same realm use different login flows?
Yes, admins can bind a custom flow to one specific client app in the realm settings. Other apps in the same realm will keep using the default browser or API login flows.
Do login flows control what a user does inside a database session?
No, login flows only verify identity and issue tokens when a user signs in. They do not inspect SQL queries, block dangerous commands, or rewrite sensitive data during an active session.
Related guides
In this post