A Keycloak container and a realm JSON file let you arrive with a working login flow, though only the client's real IdP can confirm go-live.
In brief
- Keycloak is open-source IAM under the Apache 2.0 license, and has been a CNCF incubating project since April 2023.
- It can run on a laptop as a stand-in IdP to test an SSO flow end to end, with the realm loaded from a JSON file.
- Keycloak behaves like Keycloak, not like Okta or Entra, so a check against the client's real IdP is still needed before go-live.
Sooner or later, once an application goes into an enterprise, the client’s IT team asks the question: which identity system will our users sign in through, and how?
If that is the moment you open the OIDC documentation for the first time, the meeting becomes a lesson. Keycloak lets you arrive with a login flow already running on your own laptop.
This is no niche tool. Keycloak is an open-source IAM project under the Apache 2.0 license, and in April 2023 the CNCF Technical Oversight Committee voted to accept it as an incubating project.
The reason FDEs need it lies elsewhere. WorkOS observes that testing SSO the traditional way requires an IdP account and test users, which takes real effort. For an FDE, that account usually belongs to the client’s IT department and may not have been granted when the project starts, yet you still have to show the application can integrate.
What can Keycloak do for you in the field?
Keycloak’s homepage sets out to make adding authentication to applications take as little effort as possible. More important for FDEs, it is built on standard protocols: OpenID Connect, OAuth 2.0 and SAML, the same ones the client’s IdP uses.
That is why many teams use it as a practice ground. PuppyGraph’s documentation runs a local Keycloak as a stand-in IdP, with an OIDC client and a test user already set up, so readers can walk through the whole SSO flow without a production IdP.
Artemis, the platform from the Technical University of Munich (TUM), does the same: a Keycloak container loads a ready-made realm in place of the university’s production OIDC provider.
Say you are about to deploy an internal tool for a bank that uses Entra. Before the meeting, you already know which redirect URI the application needs, which claims it reads for email and user groups, and what fails when a token expires. The questions you bring to IT become far more specific.
One command for an IdP on your machine
The official Docker getting-started page runs Keycloak in development mode and creates an admin account whose username and password are both
admin
. The command looks like this:
docker run -p 127.0.0.1:8080:8080 \ -e KC_BOOTSTRAP_ADMIN_USERNAME=admin \ -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \ <keycloak-image-from-official-guide> start-dev
<keycloak-image-from-official-guide>
is the part you fill in yourself. Open keycloak.org/getting-started/getting-started-docker, find the
docker run
command in the step that starts Keycloak, and copy the image name with its version tag exactly as it appears just before
start-dev
. Check the admin environment variable names against the page too, since they can change between releases.
Then open the admin console, create a realm for a “mock customer”, an OIDC client for your application and a few users, point your application at that realm and try signing in.
At this point you only have a hand-built IdP. The next time you start it, or when a colleague wants to run it, every click in the admin console has to be repeated.
Turn the IdP into a file anyone can rebuild
Keycloak solves this with realm import. The official documentation says a realm can be loaded at server startup with the
--import-realm
option, and that for containers the import directory is
/opt/keycloak/data/import
.
Artemis is an example worth copying. It pins the Keycloak version in its compose file and loads the realm from a JSON file in the repository on every start.
A minimal version of the same idea might look like the one below. The key point is that the repository’s
realms/
directory is mounted onto the container’s import directory and the start command adds
--import-realm
. The path comes from the current documentation; check it against the documentation for the image version you use.
services:
keycloak:
image: ${KEYCLOAK_IMAGE} # image name + pinned version, taken from Keycloak's Docker page
command: start-dev --import-realm
environment:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
ports:
- "127.0.0.1:8080:8080"
volumes:
- ./realms:/opt/keycloak/data/import # check this path against the docs for your versionTo make this file run, create a
.env
file next to the compose file with a single line:
KEYCLOAK_IMAGE=
followed by the image and tag you copied from the Docker page. Commit that
.env
file as well: the pinned tag is what lets colleagues build exactly the same IdP as you, rather than a newer release that behaves differently.
The file
realms/mock-customer.json
needs only one client and one test user for a trial run. The illustrative excerpt below keeps the essentials; a real export from the admin console is much longer:
{
"realm": "mock-customer",
"enabled": true,
"clients": [
{
"clientId": "your-app",
"publicClient": true,
"redirectUris": ["http://localhost:3000/callback"]
}
],
"users": [
{
"username": "employee1",
"email": "[email protected]",
"enabled": true,
"credentials": [{ "type": "password", "value": "test", "temporary": false }]
}
]
}The approach to follow: configure the realm by hand once, export it to JSON, add accounts that play the client’s actual user groups (employees, managers, admins), then commit the file to the repository alongside the compose file. From then on, anyone on the team who runs
docker compose up
gets the same IdP, and the demo depends on nobody’s memory.
Three common mistakes on the first setup
Most of the time lost setting up a local IdP goes on a few small details rather than on Keycloak itself. The table below lists what to check first when sign-in fails.
| Symptom | Usual cause | Fix |
|---|---|---|
| Sign-in succeeds but is rejected on return to the application | The redirect URI declared in the client does not match the address the application actually calls | Compare character by character: scheme, port, path, trailing / |
| You edit the realm JSON file but see no change after a restart | The realm already exists on the server, so the import step is skipped | Rebuild from a clean instance or delete the old realm before importing |
| Keycloak starts but no realm is loaded | --import-realmis missing, or the volume does not point at the right import directory | Check the start command and mount path against the docs for the version in use |
The first is common OIDC experience, and it will come back in the client’s environment. The second comes straight from Keycloak’s rules: if the realm already exists, the import is skipped. Write both into the README so colleagues do not lose an afternoon.
A laptop cannot replace the client’s IdP
The first limit sits in the start command itself. Development mode with
admin/admin
suits a local machine only; never let that configuration slip into any of the client’s environments.
The second limit is fundamental. SSOJet puts it plainly: Keycloak runs locally with a single
docker run
command, but it behaves like Keycloak, not like Okta or Entra. Claim names, group configuration and policies can differ from one IdP to the next.
SSOJet also describes the rhythm many teams choose: use a mock IdP during development and in CI, then test once against the client’s real IdP before launch. That is how to plan: the laptop confirms the application handles the standard flow correctly, and the session with IT is reserved for the client’s own specifics.
So do not start by learning every Keycloak feature. Get the basic OIDC flow solid first: realm, client, redirect URI, token and claim. Once you understand them on Keycloak, you will read any enterprise IdP’s documentation faster.
Final exercise: does the “managers” group really reach the token?
Most enterprise applications ask not only “who signed in” but also “which group do they belong to”. This exercise is worth doing before you consider your environment finished.
In the
mock-customer
realm, create a
managers
group and assign it to a new test account, such as
manager1
. Configure the client so group information goes into the token, then sign in as
employee1
and as
manager1
in turn. Decode each user’s ID token and compare: only
manager1
’s token should carry the
managers
group claim.
Once you see that claim, have the application read it to open or lock an admin page, then export the realm again so the new group is in the JSON file. You now have the most specific question for the client’s IT team: in which claim, and under what name, does their IdP send group information?
A small repo is worth more than a line on your skills list
A repository containing a sample application, a compose file and a realm JSON with ready-made test users is evidence an FDE recruiter can run for themselves. On your CV, describe the outcome: built a reproducible SSO environment to test OIDC integration before connecting to the client’s IdP.
The next time a “kickoff with IT” appears on your calendar, set aside an evening beforehand for Keycloak. You will walk into the meeting with the right questions instead of a list of unknowns.
Was this article useful?
Thanks for the feedback!