0009: Every request, message and job runs as an explicit caller; no caller means no access
Status: Accepted ยท Date: 2026-10-13
Contextโ
Entity isolation is enforced in one place, EntityGuard, through ICallerContext.CanAccessEntity. The HTTP
implementation treated "no HTTP user" as a trusted internal call, so every message consumer and job could act on every
entity. That was true by accident: anyone able to publish to the broker could act on any entity, and a new background
path (or a bug that dropped the user) would silently get full access. Audit rows had no caller outside HTTP, and
integrations:admin also granted every entity, so an admin token meant for configuration could read every document.
Decisionโ
- An ambient
CallerScope(anAsyncLocal, so it reaches nested scopes and audit writes) names the caller for work outside a request:- message consumers run as their publisher (
MessageCallerFilter, the outermost consume filter). WithMessaging:Publishersconfigured, the publisher is the AMQPuser_id, which RabbitMQ verifies, and its entities come from configuration. Without it, every message is trusted for every entity, as before; - scheduled jobs run as the system (
JobRunner),system:<job>; - HTTP requests use the token, with
CallerScopeonly recording the entity for audit.
- message consumers run as their publisher (
- No caller means no entity access.
HttpCallerContextdenies when there is neither a scope nor a signed-in user. integrations:adminimplies every operation scope but not entity access.- The caller is recorded everywhere:
created_by/modified_bycolumns, the append-onlyadmin_audittable for money and configuration changes (same transaction as the change), andprovider_call_audit(now with the entity).
Consequencesโ
- A new background path must begin a
CallerScope(tests that call services directly do the same), or it fails closed with403 entity_forbidden/_error. - Enabling publisher trust needs one broker user per publishing service, each setting
user_id(see the runbook). Redeliveries keep the original publisher: our own broker user carries it inIntegrations-Publisher, a header trusted only on messages from that user. - Admin tokens that also need data must ask for
entities:allor entity claims: a breaking change, in the CHANGELOG. - The ambient scope is invisible in method signatures. The alternative, passing a caller through every service call, touched every Application method for the same result.