Setting up SSO with Keycloak - edmozley/freeitsm GitHub Wiki
A complete, copy-paste walkthrough for standing up Keycloak in Docker as an OpenID Connect identity provider and wiring it into FreeITSM. Keycloak is free, open-source, and the easiest way to evaluate FreeITSM's SSO / OIDC support β but the same FreeITSM steps apply to Entra, Okta, Google, etc.
This guide uses Keycloak's development mode (plain HTTP, throwaway settings). It's perfect for local evaluation but not for production β see Going to production at the end.
- Docker installed and running (Docker Desktop on Windows/Mac).
- FreeITSM running and reachable in a browser (this guide assumes
http://localhost/freeitsm-app/). - Port 8080 free (Keycloak's default; FreeITSM stays on your web server's own port).
Create a folder for the stack (keep it outside your web root β it isn't part of FreeITSM), e.g. C:\Users\<you>\docker\keycloak\, and add a docker-compose.yml:
services:
keycloak:
image: quay.io/keycloak/keycloak:latest
container_name: keycloak
command: start-dev # dev mode: plain HTTP, no TLS certs needed
environment:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
ports:
- "8080:8080"
volumes:
- keycloak_data:/opt/keycloak/data # persists realm/clients/users across restarts
volumes:
keycloak_data:Start it:
docker compose up -d # first run pulls the image (~400 MB)
docker compose logs -f # watch it boot (optional)When it's up, open http://localhost:8080 β Administration Console and log in with admin / admin.
Useful commands later:
docker compose down # stop (keeps your data)
docker compose down -v # stop AND wipe the realm/users/clientsTip β a proper admin: the
admin/adminaccount is a temporary bootstrap account. For anything beyond a quick test, create a permanent admin: in the master realm β Users β add a user β set a password (toggle Temporary off) β Role mapping β assign theadminrealm role.
A realm is an isolated space for your application's users and clients (keep them out of the master admin realm).
- Top-left realm dropdown β Create realm
-
Realm name:
freeitsm - Create
The dropdown should now show freeitsm β everything below happens inside this realm.
The client represents FreeITSM inside Keycloak. Clients β Create client.
Step 1 β General settings
-
Client type:
OpenID Connect -
Client ID:
freeitsm-app(this is the Client ID you'll enter in FreeITSM) -
Name:
FreeITSM - Next
Step 2 β Capability config
- Client authentication: On (makes it a confidential client β it gets a secret)
- Authorization: Off
- Authentication flow: tick Standard flow only
- Next
Step 3 β Login settings
-
Root URL:
http://localhost/freeitsm-app/ -
Home URL:
/ -
Valid redirect URIs:
http://localhost/freeitsm-app/api/auth/oidc_callback.php(this is the redirect URI shown on FreeITSM's System β Single Sign-On page β copy the exact value from there) -
Valid post logout redirect URIs: both of these, one per line (Keycloak matches them exactly):
-
http://localhost/freeitsm-app/- the analyst login -
http://localhost/freeitsm-app/self-service/login.php- the self-service portal. Before 2.10.0 this guide listed only the first, so signing out of the portal ended on Keycloak's "Invalid redirect uri" page. System β Single Sign-On shows both for your install, each with a Copy button.
-
-
Web origins:
http://localhost - Save
Now open the client's Credentials tab and copy the Client secret β you'll paste it into FreeITSM in step 5.
Users β Add user:
-
Username:
alice -
Email:
[email protected](needn't be real β no email is sent; it's used to match/identify the analyst) - Email verified: On
- First / last name: anything
- Create
Then Credentials β Set password, enter a password, toggle Temporary off, Save.
In FreeITSM go to System β Single Sign-On:
- In Global settings, turn Enable single sign-on on and Save.
- Under Identity providers click Add and enter:
-
Display name:
Sign in with Keycloak -
Issuer URL:
http://localhost:8080/realms/freeitsmβ click Test (should report Discovery OK) -
Client ID:
freeitsm-app - Client secret: (paste the value from Keycloak's Credentials tab)
-
Scopes: leave as
openid email profile - Enabled: on
- Auto-create users (JIT): on (simplest for testing β auto-creates the analyst on first login; leave Default module access blank only if you're happy the user gets full access)
-
Display name:
- Save.
- Log out of FreeITSM (or use a private/incognito window) to reach the login page.
- Either type
[email protected]and click Continue, or click the Sign in with Keycloak button. - You're redirected to Keycloak β sign in as
alice/ (the password you set). - Keycloak redirects back and FreeITSM logs you in. With JIT on, an analyst for Alice is created and linked automatically.
That's a full OIDC round-trip working end to end. π
| Symptom | Likely cause / fix |
|---|---|
| "Invalid parameter: redirect_uri" at Keycloak | The Valid redirect URIs in the client doesn't exactly match FreeITSM's callback. Copy the URI from System β Single Sign-On verbatim (scheme, host, path). |
| "Security check failed (state mismatch)" | Session/cookie was lost mid-flow, or you reused an old login tab. Start the sign-in again from the login page. |
| "ID token nonce/issuer/audience mismatch" | Issuer URL is wrong (must be http://localhost:8080/realms/freeitsm, no trailing slash needed) or the client ID doesn't match. Re-run Test. |
| "Token exchange failed: invalid_client" | Wrong/blank client secret, or Client authentication wasn't On. Re-copy the secret from Keycloak's Credentials tab and re-save the provider. |
| "Your email is not verifiedβ¦" | Set Email verified: On for the user in Keycloak. |
| No "Sign in with Keycloak" button | Enable single sign-on is off, or the provider isn't Enabled. Hard-refresh the login page (Ctrl+F5). |
| Clock-skew / expiry errors | The token validator allows 60s of leeway; make sure the host clock and the container clock are roughly in sync. |
Development mode (start-dev, HTTP, the in-container database) is for evaluation only. For a real deployment:
- Run Keycloak in production mode (
start) behind HTTPS with a valid certificate, and setKC_HOSTNAME. - Use an external database (PostgreSQL) rather than the dev store.
- Replace the bootstrap
admin/adminwith a real admin account and a strong password. - Use HTTPS URLs for the FreeITSM redirect URI, and configure FreeITSM behind TLS too.
- Consider Keycloak's own MFA, brute-force detection and session policies β with SSO, the IdP owns authentication and MFA.
- Single Sign-On (SSO / OIDC) β the feature reference (configuration, account mapping, break-glass, other providers)
- Security β wider authentication and encryption details