Documentation/ Decision records
ADR 0013: Keycloak is the mandatory OpenID Connect provider
Status: Superseded by ADR 0037. Keycloak remains the optional managed adapter; it is no longer the mandatory identity provider.
Context
Karyo is signed into by operators on shared floor devices, by office staff at desks and by administrators, and it has to support integrating systems. It is installed on a host the operating company controls, so identity has to run there too; a hosted identity service would make every installation depend on a third party and on that party's pricing.
The security features a warehouse installation needs - brute-force protection, multi-factor authentication, federation with a corporate directory, session management, an audit of sign-ins - are exactly the ones that are expensive and risky to build.
Decision
- Keycloak is the only identity provider. There is no built-in user store and no alternative
authentication mode. It runs as its own container, proxied by nginx at
/auth/(ADR 0022). - The application validates bearer tokens with Quarkus OIDC against the
karyorealm, as thekaryo-backendclient. - The realm has three Karyo clients:
karyo-web- public; used by both front ends; authorization code with PKCE (S256) andcheck-sso; exact redirect URIs underKARYO_PUBLIC_ORIGINfor/,/m/and their silent check pages; no direct access grants.karyo-backend- confidential service account; the token audience the application validates and the account that reads Keycloak events and users for the sign-in audit.karyo-admin- confidential service account used only for user administration through the Keycloak admin API.
- Karyo's own claims come from user attributes through mappers on both token-issuing clients. Managed Keycloak fixtures owns the current mapping; ADR 0014 and ADR 0015 own its scope semantics.
- Roles are realm roles: fine-grained permissions such as
inventory-readandorder-write, and composites (ADMIN,MANAGER,OPERATOR,RECEIVER,VIEWER,INTEGRATOR). - Two realm definitions ship. The development realm carries demonstration users. The production realm carries no human users: the first administrator is provisioned from one-time bootstrap credentials supplied at deployment, and bootstrap access is then retired.
- Sign-ins are audited from Keycloak. A scheduled poller reads the Keycloak events API and
journals
LOGIN,LOGOUTandLOGIN_FAILED(ADR 0010).
Consequences
- Authentication is standard OpenID Connect. Federation, multi-factor authentication and brute-force protection (on in the production realm, five failures) come from Keycloak rather than from Karyo code, and tokens are validated locally once the signing keys are fetched.
- Keycloak is a fourth container with its own database schema and memory footprint, and its start, including the first realm import, gates the application's start.
- A revoked token stays valid until it expires.
- Mappers must stay aligned across both token-issuing clients and both realm files. A missing mapper does not fail: the claim is simply absent and the application falls back to its restrictive defaults.
- A realm file is imported only when the realm does not yet exist, so changing an installed realm is a maintenance procedure rather than a redeploy (Deploying).
- No client for an integrating system ships. Direct access grants are off on every client, and
karyo-webis the only client with a standard flow; it is bound to the deployment's own origin. An integrating system needs a provider client of its own that obtains akaryo-apiaccess token, and a reviewedSERVICEprincipal bound to that client's issuer and subject. The realm roles,INTEGRATORandintegration-readincluded, authorize nothing: a grant does (ADR 0048, Identity for an integrating system).
Alternatives considered
- A hosted identity service (Auth0, Firebase Authentication). Rejected. It cannot run on a customer-controlled host, per-user pricing is prohibitive when one warehouse has fifty to two hundred operators, and it moves identity data out of the customer's control.
- Karyo's own authentication and token issuing. Rejected. Authentication is a solved problem, and building it in-house means owning every security property - federation, multi-factor authentication, brute-force protection, audit - that an identity provider supplies.
- Keycloak as optional, with a built-in fallback user store. Not adopted. The cost recorded against it is two authentication code paths to maintain; no other reason is recorded.
Evidence
services/karyo-app/src/main/resources/application.yaml,quarkus.oidc, quarkus.keycloak.admin-client- OIDC validation askaryo-backend, and thekaryo-adminadmin clientservices/karyo-app/src/main/resources/application.yaml,karyo.auth-audit- the sign-in audit poller's switch and intervalinfrastructure/keycloak/karyo-realm-prod.json- the production realm: three clients, their flows, mappers and roles, no human usersinfrastructure/keycloak/karyo-realm.json- the development realmfrontend/web/src/lib/keycloak.ts,OidcSession.init, createLoginRedirectandfrontend/mobile/src/lib/keycloak.ts,OidcSession.init, createLoginRedirect-check-sso, PKCES256and the silent check pagesservices/karyo-app/src/main/kotlin/com/karyo/app/auth/KeycloakEventPoller.kt,KeycloakEventPoller- sign-in events polled through thekaryo-backendservice accountscripts/deploy-server.sh,bootstrap_credentials_required, bootstrap_credentials_assigned- the one-time bootstrap credentials required for a fresh production realminfrastructure/docker/nginx/nginx.conf,location /auth/- Keycloak proxied at/auth/
Related
- ADR 0014 - what
client_idmeans - ADR 0015 - what
principal_kindmeans and why it fails closed - ADR 0016 - the two front ends that share
karyo-web - Identity and tenancy - claim extraction and scope resolution
- Users, roles and permissions - the role vocabulary in use
- Identity for an integrating system - the machine-caller gap in full