Identity and tenancy
Who a request is, which Business Units and Facilities it may touch, and what enforces that.
Derived from libs/karyo-security/,
libs/karyo-common/src/main/kotlin/com/karyo/common/domain/BaseEntity.kt, the migration chain and
services/karyo-app/src/main/resources/application.yaml.
Silo tenancy
One instance per Company
(ADR 0014). The Company has Business Units, and a
Business Unit has Facilities (ADR 0040).
A positive business_unit_id identifies a Business Unit, not a separate SaaS customer or a permission.
There is no Business Unit row at id 0. Configuration key 0 denotes the Company layer and owns no Facility. Operational rows store only facility_id; writers
name it explicitly and readers derive the Business Unit from its immutable parent. Six master-data
and configuration tables retain business_unit_id. The database never chooses a Facility for a writer
(ADR 0050).
principal_kind (ops or business_unit_user) and the actions a principal holds are independent axes
(ADR 0015,
ADR 0048). Kind grants no action; it
decides which stored grants are admitted: a Company grant counts only for an ops principal, and an
business_unit_user principal's grants count only inside its own Business Unit.
Authentication and principal projection
Figure 1. Authentication proves a credential; Karyo's principal, binding and grants decide
application identity and authority. Derived from PrincipalSecurityIdentityAugmentor.kt,
TenantFilter.kt, CurrentAccessService.kt and auth migrations; source
docs/diagrams/14-principal-identity-boundary.mmd.
Quarkus OIDC validates access-token signature, time, exact issuer, sub, RS256 and the explicit
karyo-api audience. The deployment-configured karyo.identity.claims.* paths map provider claims
for username, Business Unit, principal kind and tenant code; there is no role claim path.
PrincipalSecurityIdentityAugmentor then resolves the exact (canonical issuer, opaque subject)
pair. The same subject from a different issuer is a different credential. Issuer aliases are
exact, explicit, attested rows; Karyo does not trim, fold case or match an email or username.
The resolved Karyo principal supplies the stable UUID, account/access state, principal kind and
approved affiliation. Unknown, unlinked, suspended and retired identities are refused. The
augmentor rebuilds the security identity without the token's roles, so no realm role, group or
scope survives as authority
(services/karyo-app/src/main/kotlin/com/karyo/app/auth/PrincipalSecurityIdentityAugmentor.kt, PrincipalSecurityIdentityAugmentor.builder).
Identity-store failure denies access. A completed migration marker is required before real JWT
traffic is accepted; first login never creates a principal.
Rule R governs the kind and Business Unit claims
(PrincipalSecurityIdentityAugmentor.resolve,
ADR 0048). The stored kind and
affiliation are authoritative, and a claim can only confirm or narrow them:
- An absent claim uses the stored value, so a provider without Karyo's custom claims works.
- A present Business Unit claim must equal the stored affiliation (
0means none), or the token is refusedaffiliation-mismatch. An affiliation changed in Karyo therefore refuses a still-valid token that named the old unit. - A kind claim of
business_unit_usernarrows a storedopsprincipal to the Business Unit kind;opson a storedbusiness_unit_userprincipal is refusedprincipal-kind-mismatch. - The default Business Unit claim and managed Keycloak user attribute are
business_unit_id. Production accepts kind valuesopsandbusiness_unit_user;owneris refused. - A malformed kind or Business Unit claim is refused (
invalid-principal-kind-claim,invalid-affiliation-claim).
TenantFilter receives the normalized ActorSnapshot from the augmented security identity and
populates TenantContext: principal/binding UUID, source issuer and subject provenance, display
username, clientId (the Business Unit id), tenant_code, principal_kind and the held actions. The raw
external subject remains provenance, not an ownership key.
Every call declares its action. Each REST method outside identity self-service and public
routes declares one catalogue action with @DeclaredAction. TenantFilter refuses a method that
declares none with 500 action-undeclared and a caller that holds the action nowhere with 403
action-not-granted, then scopes the request to where that action holds
(services/karyo-app/src/main/kotlin/com/karyo/app/auth/TenantFilter.kt, declaredAction and
resolveGrantedScope). Every
@Scheduled job and agent tool declares an action too. The catalogue, the standard profiles and
the declaration guard are in
users, roles and permissions.
Scope resolution
FacilityScope represents the Facilities a request may use. There is no legacy Business Unit scope
API; Business Unit visibility uses reachesBusinessUnit, while administration checks the action at
the Business Unit or Company node. There is no activation marker: for the
active Karyo principal UUID of every request that arrives with a provider issuer, TenantFilter
resolves the Business Units and Facilities where the method's declared action is granted
(TenantFilter.resolveGrantedScope). A Company grant reaches every unit and Facility, a Business Unit grant its
unit and that unit's Facilities, and a Facility grant that Facility with its unit as context. An action
granted in one Facility never travels to another Facility, even one where the caller holds other
actions. Missing grants yield an empty set, not Company authority or unscoped access. A narrow OPS grant cannot
read a sibling Business Unit. The issuer-less identity that exists only for resource tests has no
grants; its actions come from the test classpath's translation of its role strings, it keeps its
affiliation-derived unit scope, and its Facilities follow its kind (OPS all, BUSINESS_UNIT_USER its unit's).
Only this issuer-less test identity keeps the synthetic client_id claim.
X-Karyo-Business-Unit-Id selects one authorized positive Business Unit and X-Karyo-Facility-Id
one authorized Facility. A selected Business Unit leaves only its own Facilities in play, a Facility that
belongs to another selected unit is refused, and selecting only a Facility selects its unit. Invalid or
unauthorized selection is refused without disclosing the sibling's contents. The Facility an operation
acts in (TenantContext.operationalFacilityId) is the selected one, else the only authorized one; an
absent or ambiguous choice is a 403 facility-context-required. The selections and resolved sets have
their own TenantContext fields; clientId remains approved affiliation, including for /me, Users
visibility and personal layouts. A token claim alone does not authorize a selected unit. See
ADR 0038 and
ADR 0040.
The console and floor app obtain authorized Facilities from /api/v1/me and carry selection on
operational requests. A Business Unit header alone works only when it implies one Facility.
Operational bodies and responses do not carry a Business Unit ownership field; unknown JSON fields cannot authorize
anything. Products and substitutions resolve their catalogue from the operation's Facility, so two
unit catalogues in reach require a Facility choice. Users' affiliation field is not an operational
owner picker; it requires users.manage at the target Business Unit or Company node. Warehouse setup
names the active Business Unit and Facility it builds for.
Read and write scopes are distinct fields: use the appropriate set before listing,
aggregating, looking up or mutating rows. For a provider-token request both sets are the units and
Facilities where the declared action holds (TenantFilter.resolveGrantedScope); the write-only fixture
actAsWriteOnlyGrant holds a write grant without a read grant in tests, to prove a consumer reads the
right set.
Entity-to-entity consistency checks (for example, an order line and the product it names must
belong to the same Business Unit) remain independently necessary.
readFacilityScope() means exactly the readable set, also inside a mutating request. No request
kind substitutes one set for the other.
A mutation's own internal reads normally use the Facility of the entity whose owner was already
authorized - the shipment, unit load, pick, task or receipt line - and pass it to the port. Allocation
instead consumes the type carried by the mutation event; weight recomputation reads measures of
products referenced by already-held stock, whose owner may differ from the product's. The consumer
inventory below records these boundaries. None adds a read grant or widens public reads.
The product lookups in ReceiveLineValidator, AsnService, AsnUlAdviceService, OrderService,
FixAssignmentService and ItemDataAreaService consult no read grant: they name the owning Business
Unit and see only that unit's products.
Every product read names its owner (ProductLookup.findById(id, clientId), findNamesByIds,
findMeasuresByIds) and returns only that unit's products. A product a write references therefore
belongs to the Business Unit the row is written to: a readable product of a sibling unit is refused as
an invalid reference, so an order, ASN line, receipt, fixed assignment or item-area row never carries
another unit's product. No read grant is added or consulted. There is no ambient overload.
findMeasuresOfHeldProducts stays owner-independent: its caller already holds the product ids.
StockCountingPort takes the Facility like every other inventory port, so count start has no
exception: StocktakingService works in the Facility of the request and passes it to
findStockAtLocation, lockForCount, releaseCount, applyCount, recordMatchCounted and the
found-stock methods (recordFoundStock, approveFoundStock, rejectFoundStock) alike. Stock outside that Facility is unknown to the port. This adds no read grant and does not
change readFacilityScope(). The existing operationalWrite flag, set from the endpoint's declared
scope kind (ADR 0039),
selects the scope for operational scalar/lookup ports. It does not replace readable grants with
writable grants in readFacilityScope().
Locations and the rest of the layout work in one Facility
(TenantContext.operationalFacilityId). There are no shared locations: an OPS principal that names
neither a Business Unit nor a Facility is refused before anything is read or written, and no
Facility can belong to configuration key 0 (the facilities_business_unit_positive constraint, V1211), so no layout
row can. layout/api/v1/LocationResourceTest and layout/FacilityLayoutScopeTest cover both.
The layout, product-policy, transport-order and inventory ports take the Facility (FacilityId) and
have no ambient overload and no overload that names a Business Unit
(ADR 0042). The inventory reads
StockSummaryLookup.summaryInLocations, PurgeBlockerLookup and ReservationRefMover take the
Facility too. StockUnit, UnitLoad
and InventoryJournal are Facility-owned (facility_id), and a lookup outside the named Facility finds
nothing. A targeted reserve or release of a stock unit that exists in another Facility is refused
(Forbidden) rather than read as "gone", so a wrong Facility cannot pass as a missed reservation. A Facility belongs to one Business Unit, so stock
in it has that unit as owner and a cross-owner check inside one Facility has nothing to compare.
Fulfilment, waves, streaming, cross-dock, the replenishment scan and work dispatch name their
Facility too (ADR 0045), and so
do the monitors, reporting, forecasting, simulation, slotting and the document archive
(ADR 0046). No
operational caller reaches a port through the unit's default Facility; only the demo seeder and
warehouse setup start from a Business Unit and ask OrganizationLookup.findDefaultFacility for its
only Facility. There is no ownership change: POST /api/v1/unit-loads/{id}/change-client and
UnitLoadService.changeClient are removed, because no movement crosses Facilities. The goods ship
out of the old Business Unit and are received in at the new one.
The order ports (DeliveryOrderLookup, OrderStrategyLookup, OrderProgressionPort,
CrossDockOrdersPort, OrderReleasePort, StreamingReleasePort, GoodsReceiptLookup) and the count
service take the Facility as well, with no ambient overload and no clientId overload
(ADR 0044). ASNs, goods receipts, delivery
orders and the count rows are Facility-owned, and their numbers are unique within the Facility. The
order and receipt events carry the Facility, so the putaway task, the cross-dock interceptor and the wave
observer act in it.
Mutation consumer inventory
The inventory distinguishes authorized mutation-internal lookups from public reads, scheduler
work and deliberately fail-closed references. Test classes below live under
services/karyo-app/src/test/kotlin/com/karyo/. The new write-only regressions use
actAsWriteOnlyGrant, which sets an empty readable Business Unit set. Pack and unpack tests instead prove
that another Facility's unit load is untouched; they are not write-only regressions. A shared implementation is identified as such, not counted as a
separate executed scenario.
| Consumer | Lookup boundary | Behavioral coverage |
|---|---|---|
ShippingService.dispatch / DefaultStockPicker.shipContainer |
The authorized shipment's Facility | fulfillment/ShippingServiceTest: write-only dispatch marks the shipment shipped, consumes packed stock to DELETABLE and completes the order. inventory/service/DefaultStockPickerShipTest: write-only shipping of the shipment Facility's stock, and nothing shipped for a unit load in another Facility. |
AdHocShippingUnitService.addAdHocUnit / packAdHocContainer |
The authorized request's Facility | fulfillment/AdHocShippingUnitServiceTest: write-only attachment changes ON_STOCK stock to PACKED. |
DefaultStockPicker.packContainer / unpackContainer |
The Facility the caller names | inventory/service/DefaultStockPickerPackTest and DefaultStockPickerUnpackTest: a unit load of another Facility is untouched. |
UnitLoadWeightCalculator.recalculate / applyMeasure |
The authorized stock rows' item ids; measures read by id (findMeasuresOfHeldProducts), independent of read grants and of the product's owner |
inventory/service/UnitLoadWeightTest: write-only amount change calculates 20.000; clearing an override restores 17.500; stock handed to another owner keeps its product's weight (17.500). |
LocationAllocationService.charge |
Transfer/revive event carries the unit-load type; no ambient lookup | layout/service/LocationFinderCapacityTest: write-only move charges allocation 50. Revive shares charge; there is no separate write-only revive regression. |
ChainContinuationService |
The predecessor order's Facility | tasks/TransferChainFlowTest: write-only successor reservation uses its type's constraint percent, 40. |
TaskService receipt, manual move and start/re-suggestion |
The receipt event's Facility, the authorized request's Facility, or the order's own Facility | Three write-only cases in tasks/TransportOrderPortTest: released putaway with suggestion, correct move source/label, and re-suggestion on start. |
ConfirmVariantService.completeAsMerge |
The order's Facility | tasks/ConfirmMergeFlowTest: write-only merge finishes at the target location with folded amount 55. |
| Location finder occupancy and product default strategy | The Facility the putaway is for; the default strategy is read from that Facility's product policy | layout/service/LocationFinderAreaTest: write-only lookup still hides area B behind older stock in A. LocationFinderStrategyOwnershipTest: resolves the owner's product strategy and zone. |
PickOrderService.captureActuals and bulk short-pick lookup |
Authorized pick owner | fulfillment/PickConfirmServiceTest: write-only confirmation records lot and best-before. The bulk path shares the owner-bound lookup; this test is not a separate bulk-short-pick scenario. |
DefaultStockCountingPort.findStockAtLocation / recordMatchCounted |
The count's Facility, named by the caller | inventory/StockCountingPortEnumLockTest: write-only enumeration, lock and release. StockCountingPortReconcileTest: matching count and differing adjustment. |
ExtinguishService caller-supplied stock/unit-load ids |
The resource names the Facility of the request, and the ids resolve only in it, so a named id outside it refuses the whole call with 404; no read grant is consulted | A one-Facility call has one owner, so there is no mixed-owner refusal; no separate write-only scenario is claimed. |
Product references in ReceiveLineValidator, AsnService, AsnUlAdviceService.resolveItem, OrderService, FixAssignmentService, ItemDataAreaService |
Owner equality with the written row; no read grant is consulted | A sibling unit's readable product is refused: product/service/DefaultProductLookupNamesTest. |
Pick-order entry lookups (PickOrderService.confirmPick, claim, release, getPickOrder; PickTopUpService) |
The request's resolved operational unit, which on a mutating request is resolved from write authority; this lookup is the authorization step for the pick order's owner. Everything after it uses the pick's own owner | Covered through fulfillment/PickConfirmServiceTest; no separate write-only scenario is claimed for claim, release or top-up. |
| Public stock/product/unit-load reads | Readable grants, not the writable set | security/FacilityScopesTest: with Facilities 1 and 2 readable and only 2 writable, readFacilityScope() names both and writeFacilityScope() only 2, whether or not the request writes. Mutation-internal lookups do not change the public read contract. |
StockUnitResource mutation response names and OrderService.toResponse names |
The owner of the row named; no read grant widens or narrows the answer | A write-only caller receives the mutation result with product names, as the product-reference row above; no separate write-only scenario is claimed for these name lookups. |
| Scheduler work | An explicit Business Unit id or Facility, never an unprimed request context; weight recalculateAll uses the held-product measures boundary above |
No new scheduler regression is claimed by this inventory. |
Additive organization grants
Auth V1206 adds permission actions, profiles, profile actions and allowed node levels. V1209 adds
stable principal_id ownership while retaining the old subject as migration/history evidence.
V1214 installs the 33-action catalogue, the node types each action may be granted at, and the
seven standard profiles
(services/karyo-app/src/main/resources/db/migration/auth/V1214__action_catalogue.sql, V1214__action_catalogue).
A Company grant resolves to all positive Business Units and Facilities, a Business Unit grant to
that unit and its Facilities, and a Facility grant to that Facility with its unit as context. An
action counts only at a node type the catalogue allows it at, so a Facility grant never carries
Company or Business Unit administration. Missing grants resolve to nothing. For direct calls without
a request actor, OrganizationAccessLookup resolves one action's units and Facilities with separate
read and write methods, and an action catalogued for the other mode resolves to nothing
(services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/service/DefaultOrganizationAccessLookup.kt, DefaultOrganizationAccessLookup).
Grants are the only authority for operational scope, for every endpoint, job and agent tool, and
for the administration surface; no marker switches them on and no provider role widens them.
GrantAuthority reads every active grant of the principal once per request and admits each by the
principal's kind and affiliation
(services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/service/CurrentAccessService.kt, GrantAuthority.positions),
and the same resolver serves the agent dispatch check, which runs before a request scope exists.
The read joins principal state, so a suspended principal holds nothing. /api/v1/me/access
projects the principal's held actions per node on every request, and /api/v1/me lists them per
Business Unit for the console and the floor app. The catalogue, the standard profiles and the
delegation rules are in
users, roles and permissions.
The Users administration policy
owns its independent read and record-level mutation boundaries. Revoking a grant removes its
actions from the next request, the next access projection and the next affected Users mutation,
even when the caller reuses an older valid token. Suspending or unlinking a principal still denies
every request immediately; restoring a binding does not silently create or reactivate a grant.
/api/v1/me/access reports mode SCOPED and projects the principal's grants. A BUSINESS_UNIT_USER's missing/zero
Business Unit creates no position; owner id 0 itself never supplies Company authority, and
warehouse_id is not consulted. The reviewed access manifest of scripts/identity_migration.py
retains exact issuer/subject provenance and grants by stable principal UUID, and validates Company,
Business Unit and Facility grants. It proposes a grant's actions only from the principal's legacy
compatibility roles, translated through the same gate table the standard profiles come from
(scripts/identity_migration.py, ACTION_ROLES, role_actions); those roles grant nothing at runtime.
Scope declarations and guards
Operational scope is a shared rule that more than 90 production files read, so a change to it can
break a consumer nobody opened. ADR 0039
makes that visible mechanically. The guards are ordinary tests in the nightly test and
frontend jobs; none needs a live stack.
| Guard | What it fails on | Where |
|---|---|---|
| G1 | A production file that uses the raw ambient scope without @file:OptIn(com.karyo.security.RawScopeAccess::class): it does not compile |
RawScopeAccess.kt; test sources opt in through karyo.kotlin-conventions |
| G2 | No test: review keeps the config/scope-consumers.json list. G1 makes every raw-scope file opt in visibly, so review sees each new one |
RawScopeAccess.kt (G1) |
| G3 | A JAX-RS method with no @DeclaredScope; at runtime TenantFilter refuses it |
RestScopeDeclarationTest, TenantFilterTest |
| G4 | A @Scheduled method not listed with the scope it runs under (PER_FACILITY or GLOBAL) |
SchedulerRegistryTest |
| G5 | A read of clientId or principalKind on a context nothing has set |
UnprimedTenantContextTest, and the existing scheduler tests |
| G6 | A JPA entity that neither extends TenantEntity or FacilityEntity nor is classified, or a facility-owned entry that is not a FacilityConfigEntity subclass |
EntityClassificationTest |
| G7 | No source scan: review keeps out a new business_unit_id or internal clientId predicate. The isolation tests fail on a query that returns another owner's or Facility's rows |
ReadIsolationTest, CrossOwnerWriteTest, OrderFacilityIsolationTest, MultiFacilityOperationTest |
| G8 | An SPI port method with no scope parameter that is not listed with a reason | SpiScopeParameterTest |
| G9 | Console or floor code that sends a request outside the API client, writes the scope header elsewhere, creates a second query client, or changes the list of unscoped routes | scope-purity.test.ts in each front end |
A REST method declares one of eight kinds. OPERATIONAL_READ and OPERATIONAL_WRITE are declared on
the method and select read or write authority; ENTITY_OWNED, CONFIGURATION, ADMINISTRATION,
IDENTITY and PUBLIC may be a default on the resource class; SCHEDULED is the kind of a
background job. Declaring a kind does not prove it is the right one: a wrongly classified endpoint
passes every guard, so the kind is reviewed with the endpoint. The registry shrinks as consumers
move to a declared kind, and nothing here resolves a Facility grant.
Two more guards cover the declared action that sits beside the scope kind
(ADR 0048). ActionDeclarationTest
fails on an endpoint, @Scheduled job or agent tool that declares no catalogue action or an unknown
one, on a catalogue action nothing requires, and on any @RolesAllowed. G11 in
OrganizationGrantResolutionTest keeps the standard profiles of V1214 and V1604, the gate table of
scripts/identity_migration.py and the test translation of the job roles equal.
Floor queue identity and context
Offline actions capture {principalId, businessUnitId, facilityId, operationId, payloadVersion} (payload
version 2) before network I/O. The UUID comes from a successful online /api/v1/me, never the provider's token subject.
No resolved identity or writable selected unit means no enqueue. Replay keeps the captured header
and operation id even if the same principal selects another Business Unit or Facility. A different principal
neither replays nor fails the action: it stays pending on the device, bound to the capturing
principal and context, and is replayed only when that principal signs in again; the other
principal sees it as work waiting for another account and cannot send or discard it. Signing out
with queued work warns and requires explicit acceptance, and never blocks. Server-side release, cancellation and confirmation conflict detection compare the claiming principal
UUID when present, not a display name. Confirmation by a non-claimant requires explicit online
warning acceptance, including from a manager, and records both actors and time; it does not
transfer the claim. Unclaimed work needs no warning. Cancellation remains a refusal without its
existing manager override. A queued action never supplies warning acknowledgement automatically.
If the access token expires while the floor device is offline, an identity already verified by
online /me and its captured Business Unit remain available for local queuing only. This is a
deliberate offline behavior, not authorization to transmit an expired token: reconnection requires
successful renewal or fresh sign-in, followed by identity verification before replay. The banner
explains that sign-in is needed to sync. A network that reports online but cannot reach the
identity provider is treated the same way: only the provider refusing to renew ends the session,
and a timeout or network failure keeps it for local queuing. Both clients also record the access
token that /me verified and transmit only while the current token is that one, so a renewed token
whose identity is unconfirmed (another account in another tab, or /me temporarily unavailable) is
never sent under the previous principal's Business Unit; the console refuses the request and the
floor app queues it. An unreadable /me answer (captive portal page, timeout, rate limit) does not
discard the verified identity, and a replay that finds identity unresolved pauses instead of marking
work failed. There is no additional offline time limit, manager review
or notification. Explicit sign-out (with its unsent-work warning) and the cross-principal replay refusal remain in force; an
entry cannot become another user's acknowledged override. See the
floor guide.
IndexedDB karyo-offline version 2 upgrades the existing store in place. Unbound or unsupported
entries are marked failed, never assigned to the next signed-in user. Sync issues asks the operator
to check the warehouse result before discarding; discard does not undo server work. Drain device
queues before upgrading or rolling back the client. A queued action is not server confirmation.
Explicit scope without a request
A @Scheduled job and a cross-module port called directly run without a request. Neither passes
through TenantFilter, so nothing ambient says whose rows they touch. They name the scope in the
call: an inventory, layout, transport-order, order, count, fulfilment, wave, work, streaming,
cross-dock, replenishment, monitor, reporting, forecasting, simulation, slotting or document port takes a
FacilityId. A job enumerates the Facilities that have work, or every active Facility in the
organization registry when its work comes from more than one kind of row (the replenishment scan and
the monitor sweep), and runs each in its own failure boundary, so one Facility's failure does not
stop the others. No factory builds a synthetic TenantContext for them.
The trap this avoids is specific and is documented in the TenantContext KDoc
(libs/karyo-security/src/main/kotlin/com/karyo/security/TenantContext.kt): on a @Scheduled thread
and on direct port-to-port calls the request scope is active but unprimed. An unprimed context
holds no scope: reading its clientId or principalKind throws UnprimedTenantContextException
instead of answering the default 0, which used to be a silent wrong-tenant read. Only TenantFilter
or a fixture that sets one of the two fields primes a context. A caller that has to reach a port
therefore passes the Facility explicitly, and a port that reads ambient state fails loudly on a job
thread rather than answering for the wrong owner.
Journal attribution is separate from scope. A port still records who acted from the ambient actor
when a request is present, and as system when none primed one. Attribution never widens what may be
read or written. Not every call without a request is a scheduler: several REST paths hold an
explicit Facility because the entity, not the request, owns the goods, and a real human is present,
so the journal keeps naming the operator.
What actually enforces isolation
Application code, and only application code.
There is no PostgreSQL row-level security (see Data and persistence) or Hibernate tenant filter. The unused filter declaration was removed with the operational Business Unit column (ADR 0050). Hibernate filters do not cover primary-key or native-query reads and cannot supply this boundary.
Repositories and services apply Facility scope or an explicit Business Unit predicate themselves. Nothing applies it automatically to every query.
The scope predicates remain explicit repository and service responsibilities, not an automatically applied repository layer.
Schedulers and ambient context
Schedulers pass an explicit Business Unit id or Facility down rather than relying on ambient context,
as Explicit scope without a request describes. Every @Scheduled method is listed in
config/scope-consumers.json with the scope it runs under, and an ambient scope read from a
scheduler thread throws instead of reading owner 0.
One scheduler is the exception. LocationFinderService.sweepExpiredReservations renews the soft
reservations of open transport orders (one Facility at a time, through an explicit FacilityId)
and deletes expired ones in a single statement across all tenants, with no clientId at all
(.../layout/service/LocationFinderService.kt). That is correct for this job -
reservation expiry is tenant-independent and the reaper exists so a crashed putaway cannot
permanently block a location - but it is the only scheduler that departs from the pattern, and it
also happens to be the only one without ConcurrentExecution.SKIP and the only one with a
hardcoded rather than configurable interval. None of that is written down.
Provider-neutral administration
Authentication is standards-based OIDC. Keycloak is the managed default, not an identity key and
not mandatory (ADR 0037).
IdentityAdministration advertises capabilities before a caller offers lifecycle controls. The
Keycloak adapter can read/create disabled accounts, recover provisioning, update profiles and change
provider state; the SPI has no role operations, because Karyo assigns no provider roles. EXTERNAL mode advertises authentication only: Karyo makes no
provider directory or lifecycle calls and the embedded Keycloak container remains stopped.
Karyo access state and provider account state are separate. Suspending Karyo access is a local, immediate operation and does not claim to disable the provider account. The Users administration policy owns the controls offered by the console.
When Keycloak is configured, the karyo-web public client serves both browser code+PKCE flows,
karyo-backend is the API/service client, and karyo-admin is isolated for management. Both token
issuers carry the karyo-api audience mapper. scripts/migrate_keycloak_realm.py updates an
installed realm because --import-realm never changes an existing one. Keycloak sign-in event
polling is adapter-specific and disabled for external providers.
Related
- Users, roles and permissions - the action catalogue, the standard profiles and what each one may do
- Company and Business Units - the organization model
- Identity for an integrating system - tokens for machines
- Data and persistence - the schema side of the same story