Estimated read: 9 minutes
Keycloak is a free, open-source Identity and Access Management (IAM) solution. It handles authentication, authorization, single sign-on, and user management so you don't have to build any of that yourself. If your application needs login, roles, or SSO, and you want full control over your infrastructure, Keycloak is the standard.
You're three weeks into a new project. Let's call it InvoiceFlow, a B2B SaaS that lets companies track and approve their invoices. The MVP is shaping up: customers can upload invoices, approvers can sign off on payments, finance teams can run reports.
Then the founder drops a list of "small" requirements before launch:
You stare at the editor. Where do you start? Build all of this yourself, or delegate it to something that already does it well?
This is exactly the problem Identity and Access Management (IAM) solves. And Keycloak is the most popular open-source IAM server you can run yourself.
Every app has to answer two fundamental questions about every user:
Both are surprisingly hard to get right. Authentication alone needs password hashing, session management, MFA, brute-force protection, and secure logout. Authorization needs role management, scoping, and policy evaluation. Building these from scratch is one of the most common sources of preventable security incidents.
You could build all of this yourself, but doing so securely and correctly takes significant time and expertise, especially when dealing with MFA, federation, session management, and the long tail of security edge cases.
As shown in the diagram below, Keycloak runs as a separate service that sits between your users and your applications:
The architecture above shows where things sit. The sequence below shows when things happen during a single login:
In words:
{ "sub": "alice", "email": "alice@acme.com", "roles": ["approver"] }).Your application code never touches passwords, never stores credentials, never implements MFA logic, never speaks to Active Directory. Keycloak does all of it. Your app just trusts the signed token Keycloak hands over.
What happens next? When Alice performs an action (such as approving an invoice), her application sends the access token along with the API request. The backend service validates the token and checks her roles or permissions before allowing or denying the action.
Without Keycloak, you would need to:
Keycloak is an open-source IAM solution originally developed by Red Hat. In 2023 it joined the Cloud Native Computing Foundation (CNCF) as an incubating project, making it a vendor-neutral, community-driven effort backed by the same foundation that hosts Kubernetes.
The project also went through a major architectural shift: starting with version 17, Keycloak migrated its underlying runtime from WildFly to Quarkus. The result is dramatically faster startup times, lower memory footprint, and a much better fit for containerized and Kubernetes-native deployments. If you come across older tutorials referencing standalone.xml or WildFly subsystems, those apply to legacy versions only.
A few terms show up everywhere in IAM. You'll see them throughout the rest of this article:
These aren't Keycloak-specific. They are industry standards that Keycloak implements.
Now that you've seen what Keycloak does, let's look at how it organizes things internally. A few core concepts shape the admin console and your day-to-day mental model.
A realm is an isolated space for managing a set of users, credentials, roles, and clients. Think of it as a tenant boundary. A single Keycloak instance can host multiple realms, each completely independent.
For InvoiceFlow, you might run two customer realms: one for Acme Corp (federated with their Active Directory) and one for Globex (using social login + email + password). Each realm has its own users, settings, and login-page branding.
A client is an application or service that is registered with Keycloak and can request authentication. InvoiceFlow's React frontend, its Node.js backend API, and its background invoice-processing worker each register as separate clients. Clients are configured with redirect URIs, allowed scopes, and protocol settings.
Users are the people (or service accounts) that authenticate. Roles define what they can do: admin, approver, viewer. Groups let you bundle roles for convenience: a Finance group could include approver + report-viewer so that adding a new finance hire is one click.
In InvoiceFlow, Alice has the approver role in Acme's realm. Her colleague Bob has viewer. Roles can be realm-level (global) or client-level (scoped to a specific application).
Identity providers are external systems that Keycloak can federate with. Want Acme's users to log in with Google Workspace? Add Google as an identity provider in Acme's realm. Need Globex users to come from LDAP? Configure it as a federation provider. Keycloak handles the protocol negotiation and presents a unified login experience.
Keycloak doesn't just handle "who is this user?"; it also helps answer "what are they allowed to do?". Keycloak offers two approaches to authorization:
if (token.roles.includes("approver")) { ... }.Where RBAC stops being enough: RBAC works well for simple role-based access, but starts to break down when access depends on context (such as data attributes, time, geography, or relationships between users and resources).
invoice), scopes (e.g., read, approve), and policies (e.g., "only managers in EU region, only during business hours"). Keycloak evaluates them server-side and returns a permit or deny decision.Most teams start with RBAC and reach for Authorization Services (or layer their own policy engine on top) as access control requirements grow in complexity.
Every user-facing page in Keycloak (login, registration, forgot password, account management) is rendered from a theme. You can customize these to match your brand. Acme's users see Acme's login page, Globex's users see Globex's. Themes are built with FreeMarker templates, HTML, and CSS, giving you full control over the look and feel.
Keycloak is a strong fit when:
For a personal side project with a single login form, Keycloak is likely overkill. A simple JWT library or a lightweight auth helper is enough. Keycloak shines when the authentication problem is bigger than any single application.
The fastest way to try Keycloak is with Docker:
docker run -p 8080:8080 \
-e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:26.0 \
start-dev
This starts Keycloak in development mode on http://localhost:8080. From there:
http://localhost:8080 with admin/admin.The official Keycloak documentation has comprehensive guides for each step.
Be aware: there is a real learning curve. Keycloak's admin console has a lot of options, and production deployments require decisions about database backends, clustering, caching, reverse proxy configuration, and theme customization. The basics are quick to pick up, but mastering Keycloak takes time.
If you only remember five things from this article:
If you are building anything beyond a trivial side project and your users need to log in, Keycloak deserves a serious look.
At Keymate, we help teams deploy, migrate, and scale Keycloak in production, from first proof-of-concept to millions of users. If you are evaluating Keycloak or running into scaling challenges, we'd be happy to talk.
Whether you are starting fresh or scaling an existing deployment, Keymate helps teams deploy, migrate, and operate Keycloak in production.
Stay updated with our latest insights and product updates