Karyo
Documentation/ Configuration

Users, roles and permissions

Karyo 2.1.1rendered at build time
On this page

Karyo stores stable principal UUIDs, local access state, approved affiliation and exact external OIDC bindings (ADR 0037). It does not store passwords or issue login tokens. Authentication belongs to the configured OIDC provider; provider lifecycle administration is optional behind IdentityAdministration.

Authorization belongs to Karyo alone (ADR 0048). Every call declares one action from a fixed catalogue, and a principal may make the call only where a stored grant gives it that action. Provider realm roles, groups and scopes grant nothing, so this document has no role vocabulary to reconcile: "role" survives only in the title and in the inert realm fixtures below.

The Users screen lists enrolled Karyo principals. Karyo access (active, suspended, retired) is separate from provider account state (enabled, disabled, externally managed or unknown). Local suspension blocks the next request without claiming to disable an external account. Provisioning and managing principals owns the read and mutation boundaries and provider-capability restrictions. There is no provider-directory user facade: /api/v1/users serves only the affiliation reference list.

How a token becomes a principal and a scope at request time belongs to identity and tenancy, and control gating in the browser to the frontend. This document covers the actions, the standard profiles, what an administrator can grant, and what they cannot.

Managed Keycloak fixtures

infrastructure/keycloak/karyo-realm.json and infrastructure/keycloak/karyo-realm-prod.json define the optional managed realm karyo with an identical realm role set, identity claim mappers and explicit karyo-api audience mapper. They differ in exactly one thing: the development realm ships five named users with attributes and credentials, and the production realm ships none beyond the two service accounts.

The development users carry these provider attributes:

User Realm roles business_unit_id principal_kind tenant_code
admin ADMIN 0 ops SYS
manager MANAGER, integration-admin 1 ops ACME
operator OPERATOR 1 ops ACME
viewer VIEWER 1 ops ACME
tenant2-operator OPERATOR 2 business_unit_user GLOBEX

These attributes are fixtures, not authority. The realm files still define eighteen atomic realm roles and six composite job roles, assign them to the users above and map them into tokens (karyo-realm.json, roles.realm), but Karyo reads none of them: the security identity is rebuilt without token roles (services/karyo-app/src/main/kotlin/com/karyo/app/auth/PrincipalSecurityIdentityAugmentor.kt, PrincipalSecurityIdentityAugmentor.builder) and the actor carries an empty role set (PrincipalSecurityIdentityAugmentor.resolve). A development user acts only through the grants stored for its enrolled principal. The business_unit_id and principal_kind attributes feed the two claims that rule R may compare with the stored principal; they cannot widen it.

The identity attribute mappers in both realm files define the token claims. The business_unit_id mapper reads the user attribute of the same name; it does not create authority. There is no permissions mapper in either realm.

The action catalogue

Actions lists 34 action keys (libs/karyo-security/src/main/kotlin/com/karyo/security/Actions.kt, Actions), and auth migration V1214 installs the same keys with their access mode and the organization node types each may be granted at (services/karyo-app/src/main/resources/db/migration/auth/V1214__action_catalogue.sql, V1214__action_catalogue). Every action declares READ, WRITE or ADMINISTRATION; there are no deny rules.

Action What it permits Granted at
inventory.read, inventory.write, inventory.adjust Read stock, unit loads, journals and counts; move, receive into and count stock; adjust quantities Company, Business Unit, Facility
counts.approve Accept stock count results Company, Business Unit, Facility
products.read, products.write Read and change products and their Facility policy Company, Business Unit, Facility
layout.read, layout.write Read and change the warehouse layout and setup Company, Business Unit, Facility
arrangement.read Read the warehouse arrangement, which serves both the layout and the stock views Company, Business Unit, Facility
orders.read, orders.write, orders.release Read, change and release delivery orders, receipts and advices Company, Business Unit, Facility
tasks.read, tasks.write Read, create and carry out transport tasks Company, Business Unit, Facility
fulfillment.read, fulfillment.write Read picking, packing and shipping; pick, pack and ship Company, Business Unit, Facility
reports.read, reports.write Read reports; save and delete report definitions Company, Business Unit, Facility
operations.view See waves, cross-dock, monitoring, analytics, streaming and documents Company, Business Unit, Facility
operations.execute Sort, pack out, handle alerts, cross-dock and streaming Company, Business Unit, Facility
operations.supervise Plan waves, set monitors and make supervisor overrides Company, Business Unit, Facility
work.claim Claim and release work from the work inbox Company, Business Unit, Facility
work.positions.read See where each operator last stood in the Facility, by name: the floor view's people layer (ADR 0067) Company, Business Unit, Facility
documents.delete Delete stored documents Company, Business Unit, Facility
integrations.manage Manage webhook subscriptions and deliveries Company, Business Unit, Facility
organization.read Read the Company and its Business Units Company, Business Unit, Facility
demo.manage Seed and reset demonstration data Company, Business Unit, Facility
organization.manage Create and change Business Units and the Company Company, Business Unit
users.read, users.manage Read, create and manage users at an organization position Company, Business Unit
permissions.delegate Grant and revoke permission profiles Company, Business Unit
settings.manage Change system properties and document templates Company, Business Unit
home.manage Save the default Home layout Company, Business Unit
extensions.read Read the extension registry Company, Business Unit

The seven administration actions in the last rows can be granted only at the Company or a Business Unit; every other action can also be granted at one Facility.

Every call declares its action. Each REST method declares one action with @DeclaredAction on the method itself, never inherited (Actions). Only IDENTITY and PUBLIC methods - /api/v1/me, a user's own Home layout, the public auth configuration - declare none. TenantFilter refuses a Karyo method that needs an action and declares none with 500 action-undeclared, and a caller that holds the action nowhere with 403 action-not-granted (services/karyo-app/src/main/kotlin/com/karyo/app/auth/TenantFilter.kt, TenantFilter.declaredAction, TenantFilter.populateOrganizationScope). Every @Scheduled job and every agent tool declares an action too, and a tool's action equals the action of the endpoint it mirrors. ActionDeclarationTest (services/karyo-app/src/test/kotlin/com/karyo/security/guards/ActionDeclarationTest.kt) fails a build on an undeclared endpoint, job or tool, on an unknown key, on a catalogue action nothing requires, and on any remaining @RolesAllowed.

A target never travels. The seven administration actions and the configuration actions are only checked as held somewhere before an endpoint runs, so each endpoint also checks its target against the node of the grant (ADR 0048). A Company-wide target needs the action at the Company node: updating the Company; creating, deactivating or reactivating a Business Unit; the consistency scan; and the system properties, Home default and document templates of client 0 (settings.manage and home.manage). A Business Unit target must lie in a unit the action reaches: the system properties, Home default and document templates of unit N, and updating unit N (TenantContext.reachesBusinessUnit). An operations principal with the Administrator profile on one Business Unit is therefore refused every other target with the resource's own denial (422 system-property-target-forbidden or home-layout-target-forbidden, 403 company-administration-forbidden, business-unit-administration-forbidden or document-template-forbidden, or 404 for a unit it cannot reach). AdministrationTargetIsolationTest proves it with signed tokens.

Inside an endpoint, domain code can ask whether a second action holds in a given Facility (libs/karyo-security/src/main/kotlin/com/karyo/security/TenantContext.kt, TenantContext.holds), for a decision such as a supervisor override. That check never replaces the endpoint's own declared action.

Standard profiles

A grant names a permission profile, and a profile is a set of actions. V1214 installs seven standard profiles (V1214__action_catalogue.sql, V1214__action_catalogue). The first six reproduce the shipped job roles one for one; the gate table in scripts/identity_migration.py, ACTION_ROLES names, for every action, the legacy job and atomic roles that map to it, and the profiles are generated from it. The table lists fulfillment-read under VIEWER, and V1604 (V1604__viewer_reads_fulfillment.sql) added fulfillment.read to the Viewer and Receiver profiles of an installation that had applied V1214. So Viewer, Receiver, Operator, Manager and Administrator read pick orders and shipments, and only the last three hold fulfillment.write to pick, pack, ship or cancel.

Profile Holds
Viewer (viewer) arrangement.read, fulfillment.read, inventory.read, layout.read, operations.view, orders.read, organization.read, products.read, reports.read, tasks.read
Receiver (receiver) Viewer, plus counts.approve, inventory.adjust, inventory.write, orders.release, orders.write, work.claim
Operator (operator) Receiver, plus fulfillment.write, operations.execute, tasks.write
Manager (manager) Receiver, plus demo.manage, documents.delete, fulfillment.write, layout.write, operations.supervise, products.write, reports.write, tasks.write, work.positions.read
Administrator (administrator) Every action except operations.execute, operations.supervise and work.positions.read
Integrator (integrator) arrangement.read, inventory.read, orders.read, orders.release, orders.write, products.read, products.write, work.claim
Integrations (integrations) integrations.manage

Three consequences follow directly from the table:

  • Operator and Manager differ by more than rank. Only Operator holds operations.execute (sorting, pack-out, alert handling) and only Manager holds operations.supervise (wave planning, monitors, overrides). A shift lead who does both needs both profiles.
  • Administrator does not hold floor execution or supervision. It holds every administration action and every domain action, but not operations.execute or operations.supervise.
  • Seeing named operators on the floor view is its own action. Only Manager holds work.positions.read. Add it to another profile, or grant Manager, to let someone see people.
  • A profile is grantable only where all its actions are. A grant is refused when any action of the profile cannot be granted at the chosen node type (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/service/AccessGrantService.kt, AccessGrantService.requireNodeSupport), so Administrator can be granted only at the Company or a Business Unit, while the other six can also be granted at one Facility. GET /api/v1/permission-profiles reports each profile's grantable node types (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/service/PrincipalGrantService.kt, PrincipalGrantService).

OrganizationGrantResolutionTest (services/karyo-app/src/test/kotlin/com/karyo/auth/OrganizationGrantResolutionTest.kt) keeps the profiles, the Python gate table and the test translation of the job roles equal. That test translation exists only on the test classpath, for resource tests whose issuer-less @TestSecurity identities still name role strings; production supplies no translation, and its issuer-less identity holds nothing (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/service/CurrentAccessService.kt, CurrentAccessService).

How a grant becomes authority

A grant is a principal plus a Company, Business Unit or Facility node plus a permission profile (auth migrations V1206 and V1207, re-keyed to the principal UUID by V1209). A principal holds an action at a node when an active grant there names a profile with that action, the action may be granted at that node type, and the grant is admitted for the principal's kind and affiliation (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/service/CurrentAccessService.kt, GrantAuthority.positions):

  • a Company grant counts only for an operations (ops) principal;
  • a Business Unit or Facility grant counts for an operations principal, or for a principal affiliated to that Business Unit.

A Company grant reaches every Business Unit and Facility, a Business Unit grant its unit and that unit's Facilities, and a Facility grant that Facility only. Grants are read once per request (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/repository/PermissionRepositories.kt, AccessGrantRepository.activePositions), so a revoked grant stops the next request even while the caller's token is still valid. A request is then scoped to the Business Units and Facilities where its declared action holds, which scope resolution describes.

/api/v1/me returns the held actions (actions) and, for each Business Unit where any action holds, that unit's actions (services/karyo-app/src/main/kotlin/com/karyo/app/auth/AuthSessionResource.kt, AuthSessionResource.me, AuthSessionResource.currentPrincipal). /api/v1/me/access projects every held action per node. The console and the floor app show a control only when the selected Business Unit's actions include the action of the call it makes; the server still checks the exact Facility on every request.

Delegation. POST /api/v1/principals/{id}/grants and PUT /api/v1/principals/{id}/grants/{grantId}/revoke declare permissions.delegate (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/api/v1/PrincipalResource.kt, PrincipalResource.grant, PrincipalResource.revokeGrant). The delegator must hold permissions.delegate and every action of the profile at a node that covers the target node (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/service/AccessDelegationService.kt, AccessDelegationService.requireDelegableProfile). An administrator holding only the Administrator profile therefore cannot grant Operator or Manager, because it lacks operations.execute and operations.supervise. A Business Unit (business_unit_user) delegator stays inside its own unit and cannot manage an operations principal, and a business_unit_user recipient receives grants only in its own unit (AccessDelegationService). Delegation is keyed by principal UUID on both sides, so a principal of any provider can receive a grant without a provider administration call.

System, the setup account. The delegation rule means somebody must already hold a profile's actions before anyone can be granted it. On a fresh managed-Keycloak installation that somebody is System, the setup account Karyo creates once and grants all seven standard profiles at the Company (ADR 0053). System signs in to the console only, creates the first Administrator and Manager and grants each its profile, and is disabled once it confirms setup is complete (with at least one Administrator and one Manager in place) or 14 days after installation. Its grants are fixed: no grant can be added to it, the console cannot restore it, and only a server-side KARYO_SETUP_REOPEN marker reopens it. Its actions are recorded as "System (setup)", and its user record lists them (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/service/SetupPrincipalService.kt, GET /api/v1/setup). The rule itself is unchanged: an Administrator System creates still cannot grant Manager or Operator unless it also holds their actions.

A revoke needs the same authority as the grant on that node, is idempotent, is refused for the last active Company grant that carries permissions.delegate (409, AccessDelegationService.requireNotLastCompanyDelegation), and is never undone by restoring the principal: only a new grant restores the position. Each grant and revoke writes an identity change fact. The routes are in the HTTP contract; identity and tenancy owns operational scope and the HTTP contract owns /api/v1/me/access.

Access must be granted in Karyo: an enrolled principal without grants holds nothing, whatever its token says. V1214 deleted the retired standard-* profiles and every grant that named them (V1214__action_catalogue.sql, V1214__action_catalogue), so a database that held those grants needs new grants of the standard profiles.

Provisioning and managing principals

POST /api/v1/principals is the canonical provisioning route and declares users.manage (services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/api/v1/PrincipalResource.kt, PrincipalResource.create, PrincipalResource.actor). It creates a Karyo principal and exact provider binding through the disabled-first workflow below. It is the only creation route, and it creates the principal with no grants (PrincipalResource.create): the new user holds nothing until a delegator grants a profile. A provider with no creation capability (an external one) enrolls its principals with the guarded identity_migration.py enroll command instead (identity upgrade).

The goods owner is explicit, active and scope-checked; it is never inherited from the actor. The form obtains affiliation choices from GET /api/v1/users/affiliations, which declares users.read and, in the service, also needs organization.read. It lists active affiliations the actor may manage, independently of operational selection. An OPS actor may create OPS or BUSINESS_UNIT_USER principals, while a BUSINESS_UNIT_USER actor may create only BUSINESS_UNIT_USER principals inside its own Business Unit, and users.manage must reach the requested kind and affiliation (PrincipalResource.authorizedKind). A principal cannot be re-homed: affiliation and principal kind are not profile fields. The route also requires an Idempotency-Key header.

AccessProvisioningService coordinates the optional administration provider with the application database without pretending they share a transaction. In managed-Keycloak mode it creates the provider identity disabled, persists the Karyo principal, exact binding and durable GRANTS_COMMITTED marker, then enables the provider identity. A retry with the same key reconciles that workflow; a changed same-key request is refused. The key is bound to a length-prefixed HMAC-SHA-256 representation of every effective request field, including the password. The server-held key is configured with KARYO_PROVISIONING_FINGERPRINT_KEY; neither it nor the password is stored in coordination state. An authentication-only provider advertises no creation capability, so this route returns the typed unsupported-capability problem before a provider write.

Lists and detail reads (users.read) are scoped separately from mutations (users.manage). OPS actors see all principals. BUSINESS_UNIT_USER actors see their Business Unit, including OPS records there, but may mutate only BUSINESS_UNIT_USER principals and only when current users.manage authority covers the record. Each response carries allowedActions for local access, profile, credential, provider lifecycle and unlink operations; a principal summary carries no roles. The Users page consumes this list for Edit and Suspend/Restore rather than deriving authority in the browser; it does not currently expose password-reset, provider enable/disable or unlink controls. A visible record can therefore have no controls. Every direct mutation recalculates the same current grant, kind and branch boundary. A missing or out-of-scope id is reported as not found rather than revealing another unit's principal.

Local suspension and restoration change only Karyo access. Restoring a non-system principal requires an active binding; unlinking the last binding requires suspension first, and unlinking requires permissions.delegate at the Company. There is no principal delete or re-home route, so a principal created against the wrong affiliation must be suspended and replaced. Unlinked provider/subject pairs remain tombstoned and cannot be reassigned.

Profile, password and provider enable/disable actions require the corresponding advertised IdentityAdministration capability. Both password-reset routes additionally require an enrolled HUMAN principal and its unique active managed binding. Karyo refuses SERVICE password resets; machine-credential management stays with the identity provider. Karyo assigns no provider roles: the identity SPI has no role operations (services/auth-service/karyo-auth-api/src/main/kotlin/com/karyo/auth/identity/IdentityContracts.kt, IdentityAdministration), and there is no role route. Authentication-only deployments offer none of the provider actions.

warehouse_id and locale are retired

Karyo no longer mints, reads or writes warehouse_id, and it no longer reads a locale claim. There is no Warehouse entity or warehouses table, so the value never bounded anything, and nothing read the locale. Neither realm (infrastructure/keycloak/karyo-realm.json, infrastructure/keycloak/karyo-realm-prod.json) declares the attribute or maps it into a token. TenantContext and ActorSnapshot carry neither field. The create and update user requests do not take warehouse_id, and the provider update does not write it. A request body that still names warehouseId is not refused: Karyo ignores the field. The karyo.identity.claims.locale path and its KARYO_OIDC_LOCALE_CLAIM variable are gone, and setting the variable changes nothing.

Existing accounts may still carry a warehouse_id attribute, because the realms keep unmanagedAttributePolicy enabled. It is evidence only: preferred-location text is never authorization, and the access migration runbook owns how preflight archives it without granting or vetoing authority.

A running Keycloak keeps its old mapper. Keycloak imports a realm file only when the realm does not exist yet (--import-realm skips an existing realm), so editing the shipped files does not change an installation that is already running. On such an installation the warehouse_id protocol mapper stays on the karyo-web and karyo-backend clients, and the warehouse_id attribute stays declared in the user profile, until it is removed. The remaining claim is harmless: Karyo ignores it, and a token that carries warehouse_id gains no authority. The karyo-web mapper and the profile attribute need manual removal. The karyo-backend mapper goes away either by hand or through the realm migration below. To remove a mapper by hand, open the client in the Keycloak admin console, open its dedicated client scope, and delete the warehouse_id mapper.

The realm migration (scripts/migrate_keycloak_realm.py --apply) removes the warehouse_id mapper from the karyo-backend client, because it deletes every backend mapper outside its allowlist and the allowlist no longer names warehouse_id. It does not touch the karyo-web client: that mapper, and the declared user-profile attribute, still need the manual removal described above.

The admin UI uses the principal surface

Warehouse > Users and Admin > Users open /users, and both entries need users.read. The page lists stable Karyo principal ids and local access state through /api/v1/principals; it does not deep-link to the Keycloak console. Its controls follow the administration rules above.

The detail pane's Grants section lists the user's stored grants with their state. A delegator (permissions.delegate) adds a grant by choosing a permission profile and the node it applies to, from the node types the profile allows, and revokes an active grant in place. The recipient's next request carries the change, with no new sign-in. There is no raw policy editor.