A Keycloak container plus a realm JSON file is enough to walk into the meeting with a login flow that already works.

Key points at a glance

  • Keycloak is open-source IAM software licensed under Apache 2.0, and since April 2023 it has been a CNCF incubating project.
  • It can act as a stand-in IdP on your laptop, loading realms from JSON files to test SSO flows end to end.
  • Keycloak's behavior is Keycloak's behavior, not Okta's or Entra's, so you still need to verify against the customer's real IdP before go-live.

When an application enters an enterprise, the customer's IT team will sooner or later ask: which identity system will their users log in through, and how?

If that's the first time you open the OpenID Connect (OIDC) docs, the meeting turns into a lecture. With Keycloak, you can arrive with a login flow that already runs on your own laptop.

This is no niche tool. Keycloak is an open-source IAM project licensed under Apache 2.0. In April 2023, the Cloud Native Computing Foundation (CNCF) Technical Oversight Committee voted to accept it as an incubating project.

Forward Deployed Engineers (FDEs) need it, but for a different reason. WorkOS points out that testing single sign-on (SSO) the traditional way requires an identity provider (IdP) account and several test users, which are not easy to set up. For an FDE, that account is usually controlled by the customer's IT team and may not be provisioned when the project kicks off, yet you still have to prove the application can complete the integration.

What can Keycloak do for you in the field?

Keycloak's official site states its goal as adding authentication to applications with minimal effort. More important for FDEs, it is built on standard protocols: OpenID Connect, OAuth 2.0, and SAML, the same protocols customer IdPs use.

That's why many teams use it as a practice ground. PuppyGraph's docs run Keycloak locally as a stand-in IdP, pre-configured with an OIDC client and a test user, so readers can walk through the entire SSO flow without a production IdP.

The Artemis platform at the Technical University of Munich (TUM) does the same: a Keycloak container loads a ready-made realm, standing in for the school's production OIDC provider.

Imagine you're deploying 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 email and groups from, and where things break when tokens expire. The questions you bring to IT will be far more specific.

One command to run an IdP locally

The official Docker getting-started page runs Keycloak in development mode and creates an admin account with both username and password set to

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>

This part you need to fill in yourself. Open keycloak.org/getting-started/getting-started-docker, find the step that starts Keycloak, and locate the

docker run

command; copy the full image name with the version tag that appears right before

start-dev

. Also verify the admin environment variable names against the page, as they may change between versions.

Then open the admin console, create a realm for the "simulated customer," create an OIDC client and a few users for your application, point the application at this realm, and try logging in.

At this point, you only have a manually 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 redone from scratch.

Turning the IdP into a file anyone can rebuild

Keycloak solves this with realm import. The official docs explain that you can load a realm at server startup with the

--import-realm

option, and the import directory inside the container 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 startup.

A minimal version of the same idea looks like this. The key points: mount the repository's

realms/

directory to the container's import directory, and add

--import-realm

to the startup command. The paths come from the current docs; verify them against the docs for your image version.

services:
  keycloak:
    image: ${KEYCLOAK_IMAGE}   # 镜像名 + 固定版本,取自 Keycloak 的 Docker 页面
    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   # 请对照所用版本的文档核实此路径

To make this file work, create a

.env

file next to the compose file with a single line:

KEYCLOAK_IMAGE=

, followed by the image name and tag you copied from the Docker page. Commit this

.env

file too: it's the pinned tag that lets colleagues build exactly the same IdP as yours, rather than a newer version with different behavior.

For a trial run, the

realms/mock-customer.json

file only needs one client and one test user. The illustrative snippet below keeps only the essentials; a file actually exported 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 recommended approach: configure the realm manually once, export it as JSON, add accounts playing the customer's actual user groups (regular employees, managers, admins), then commit the file together with the compose file to the repository. From then on, anyone on the team who runs

docker compose up

gets the same IdP, and demos no longer depend on one person's memory.

Three common mistakes when getting started

When setting up a local IdP, most of your time isn't spent on Keycloak itself, but on a few small details. The table below lists what to check first when login fails.

SymptomCommon causeFix
Login succeeds, but the return to the application is rejectedThe redirect URI declared in the client doesn't match the address the application actually callsCompare character by character: protocol, port, path, trailing /
Modified the realm JSON file, but nothing changed after restartThe realm already exists on the server, so the import step is skippedRebuild from a clean instance, or delete the old realm before importing
Keycloak started, but no realm was loaded--import-realm was omitted, or the volume doesn't point to the correct import directoryCheck the startup command and mount paths against the docs for your version

The first mistake is an OIDC classic, and you'll hit it again in the customer's environment. The second follows directly from Keycloak's rule: if the realm already exists, the import is skipped. Write both into the README so colleagues don't waste an afternoon.

A laptop can't replace the customer's IdP

The first limitation is right in the startup command. Development mode with

admin/admin

is only suitable for your local machine; never let this configuration leak into any customer environment.

The second limitation is fundamental. SSOJet puts it bluntly: Keycloak can run locally with a single

docker run

command, but its behavior is Keycloak's behavior, not Okta's or Entra's. Claim names, group configuration, and policies can all differ between IdPs.

SSOJet also describes the rhythm many teams adopt: use a mock IdP during development and continuous integration (CI), then test once against the customer's real IdP before go-live. Plan the division of labor this way from the start: the laptop confirms the application handles standard flows correctly, while the meeting with IT is reserved for the specifics of the customer's environment.

So there's no need to learn every Keycloak feature right away. First, master the basic OIDC flow: realms, clients, redirect URIs, tokens, and claims. Once you understand these on Keycloak, reading the documentation of any enterprise IdP becomes much faster.

A closing exercise: did the "managers" group actually make it into the token?

Most enterprise applications need to know not just "who logged in" but also "which groups this person belongs to." Complete this exercise before moving on to the production environment setup.

In the

mock-customer

realm, create a

managers

user group and assign it to a new test account, for example

manager1

. Configure the client so that the token includes group information, then log in as

employee1

and

manager1

in turn. Decode both users' ID tokens and compare them: only

manager1

's token should carry the

managers

group claim.

Once you see this claim, have the application read it to grant or block access to an admin page, then re-export the realm so the new group is also saved in the JSON file. At that point you'll have the most concrete question to ask the customer's IT team: which claim does their IdP put group information in, and what is it called?

A small repository beats a line on a 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 with their own hands. When writing it on your resume, frame it as an achievement: built a reproducible SSO environment to test OIDC integration before connecting to a customer's IdP.

The next time "kickoff meeting with IT" shows up on your calendar, spend an evening tinkering with Keycloak beforehand. Walk into the meeting room with the right questions instead of a list of unknowns.

Was this article helpful?

Thanks for your feedback!

Next on the roadmap · Phase 2: Full-stack engineering skills — an API test suite you can leave with the customer takes just a few text files. Hurl runs on your laptop and in the customer's CI pipeline, and the other team can understand every line.