Skip to content

This page is for integrators, operators and engineers who need to act under a delegation programmatically, or to reason about exactly how a delegation is enforced. The administrator’s view (creating, scoping, forwarding and ending a delegation) is Delegation. The gateway plugin is also listed with the other plugins in Gateway operations, and the delegate’s permission resolution in the engine is in Engine: Permissions.

The core delegation entity and the active-delegations endpoint predate the 1.2 milestone. Scope-based permission filtering and administration inheritance were added later, but are also long-standing (pre-1.2).

A delegation is a normal data entry of the delegation entity (system id DELEGATION). Its value holds:

FieldLabelTypeRequiredMeaning
delegatorDelegatorreference (user)yesThe user whose duties and permissions are delegated.
delegated_toDelegated Toreference (user)yesThe delegate.
from_dateFrom Datedate-timeyesWhen the delegation becomes active.
to_dateTo Datedate-timeno (nullable)When it ends. null/absent means open-ended.
is_activeIs Activecategory (DelegationTypeEnum)yesACTIVE or INACTIVE: the manual on/off switch.
delegation_scopeDelegation ScopeobjectyesWhat is delegated (see below).
FieldLabelTypeMeaning
baseBasecategory (DelegationScopeEnum)The default posture: ALLOW_ALL or DENY_ALL.
exceptionExceptionarray of referencesSystem objects the base posture does not apply to. Defaults to [].
allow_administrationAdministrationarray of category (DelegationAdministrationEnum), optionalWhen it contains ALLOWED, the delegate also inherits the delegator’s administration (system) permissions.
forward_notificationsForward Notificationsboolean, default offDeliver a copy of the delegator’s in-app notifications to the delegate. Since 1.10
forward_emailsForward Emailsboolean, default offCopy the delegate on the delegator’s emails. Since 1.10

Enum values: DelegationTypeEnum = ACTIVE, INACTIVE; DelegationScopeEnum = ALLOW_ALL, DENY_ALL; DelegationAdministrationEnum = ALLOWED.

The USER entity carries an implicit relation Delegation (“delegations given by the user”, USER_GIVEN_DELEGATIONS_RELATION) onto DELEGATION through the delegator field. Since 1.6

What the exception picker offers Since 1.8

Section titled “What the exception picker offers Since 1.8”

The options offered in Exception are scoped to what the administrator creating the entry can reach:

  • A caller with a system-level grant (system viewer, editor or admin) is offered the entire published application tree: modules, views, pages, reports and service actions.
  • Any other caller sees only the views, pages and reports they hold an access right on, plus the service actions they may submit or observe, plus the ancestor nodes needed to keep those items attached to the tree.
  • An anonymous caller is offered the anonymous-enabled views and pages; a caller with no permissions at all is offered nothing.

This governs only what the picker offers. delegation_scope.exception is applied at request time as a filter over the delegator’s own permissions (see Scope enforcement), so a wider option list can never widen a delegate’s actual access.

A delegation is honoured only when all of these hold:

  1. is_active is ACTIVE.
  2. from_date <= now.
  3. to_date is null or to_date >= now.
  4. The entry state is Active (not archived or deleted).

The active-delegations query returns the delegations where the given user is the delegate (delegated_to matches). If the same delegator appears more than once, results are de-duplicated so the delegate sees one delegation per delegator. Each returned delegation has its delegator reference resolved with display metadata.

Delegation is applied per request via the X-DELEGATION-ID request header. A client that wants to act under a delegation sends the delegation entry’s id in that header; there is no server-side “delegation mode” state, and the header’s presence on each request is what activates delegation for that request. Enforcement is split between the API gateway (delegate binding, time window and identity swap) and the data service (is_active, entry state and scope).

On mobile, selecting a delegation persists the choice and reloads the app; a client-side interceptor (DelegationInterceptor) then attaches the delegation header to every request. On the web, signing out ends the active delegation. Since 1.6

Enforcement in the API gateway (Kong) runs through the custom user-delegation plugin (packaged as kong-plugin-user-delegation-0.1.0-1.rockspec, depending on lua-resty-redis-connector 0.11.0). It runs at priority 1000: after token introspection and app-token auth (which establish x-user-id), and before user-space-checker (999) and osos-access (997). The flow:

  1. Trigger. Without an X-DELEGATION-ID header the plugin passes the request through untouched.

  2. Require an authenticated user. If x-user-id is missing, it returns 400 MISSING_USER_ID.

  3. Load delegation details. It looks the delegation up in Redis under a tenant-scoped key, osos:delegation:v2:<delegation_id>, composed with the envPrefix and the tenant id (a request whose tenant is unresolved is refused with 500 APP_ERROR before any lookup). On a miss it calls GET <data_service_url>/api/v1/delegations/<id> with internal service headers (the gateway’s service identity and the shared key, plus the tenant), then caches the result for cache_ttl (default 600 s). Failure modes: a non-200 is forwarded as DELEGATION_API_ERROR; a request that fails outright returns 500 DELEGATION_API_REQUEST_FAILED; success: false returns 500 DELEGATION_API_LOGIC_ERROR; an undecodable body returns 500 DELEGATION_API_DECODE_ERROR; a Redis connection failure returns 500 REDIS_CONNECTION_ERROR. Infrastructure details (internal hosts, Redis errors) are logged at the gateway, not returned to the caller.

  4. Bind the delegation to the caller. Since 1.6 The plugin compares delegated_to with x-user-id. A delegation granted to someone else is refused with 403 DELEGATION_FORBIDDEN (“Delegation does not belong to the current user”); a delegation with no delegated_to is treated as incomplete (500 DELEGATION_DATA_ERROR). See Delegatee binding.

  5. Validate the time window. from_date and to_date are parsed from ISO 8601 date-time strings (with or without milliseconds, ending in Z or a ±HH:MM offset, which is applied) into UTC timestamps; an impossible calendar date is rejected rather than rolled over. If now is before from_date, or after a present to_date, the plugin returns 403 DELEGATION_EXPIRED. A null or absent to_date means no upper bound. Unparseable dates return 500 DELEGATION_DATE_PARSE_ERROR.

  6. Swap identity. On success the plugin rewrites the upstream headers so downstream services see the request as coming from the delegator:

    HeaderValue
    x-user-idthe delegator’s id
    x-delegatee-idthe original caller (the delegate)
    x-is-delegation"true"

The gateway reads the delegation through /api/v1/delegations/{id}, which returns only id, delegator, delegated_to, from_date and to_date. It therefore enforces only the binding, the time window and the identity swap: it does not evaluate is_active, scope or entry state. A delegation toggled to INACTIVE or archived still passes the gateway, and the data service then resolves empty or limited permissions for it.

The X-DELEGATION-ID header is supplied by the client, and the gateway fetches the delegation with an internal service call. Before this check, any signed-in user who presented a delegation id was switched into the delegator’s account. The plugin now requires the caller to be the delegation’s delegated_to, and answers 403 DELEGATION_FORBIDDEN otherwise.

The check needs both halves: the data service returns delegated_to on GET /v1/delegations/{id} (also delivered to the 1.4, 1.6 and 1.8 lines as an update), and the gateway caches under the new v2 key, so details cached before the change, which lack delegated_to, are never read back and rejected. Upgrade the data service before the gateway.

DELEGATION_EXPIRED does not disclose the delegation. The 403 body carries only details.error = "Delegation period is not current.", not the delegator, the period or the gateway’s clock. The refusal is logged at info level with the delegation id, the caller and the trace id, which is how an operator finds the delegator and the period. The web client reads only the code, and clears the active delegation.

The downstream osos-access plugin (priority 997) reads X-DELEGATION-ID and, when present, fetches a delegation-scoped user profile from GET /api/v1/users/<userId>/delegation/<delegationId>/profile, cached in Redis under shared:user-profile-<userId>_<delegationId>. With a delegation id present, view access is decided directly by whether the delegator holds the view’s access permission, rather than by the normal ownership-based check. A fixed set of view ids bypasses the delegation path and always uses the normal check:

SERVICE_CATALOG, ONGOING_INBOX, INBOX_REQUESTS,
ONGOING_MY_REQUESTS, COMPLETED_MY_REQUESTS,
ONGOING_OBSERVER, COMPLETED_OBSERVER

The data service resolves the delegate’s effective permissions in getAllDelegateePermissions(userId, delegationId); this is where delegation_scope takes effect:

  1. Load the active delegation (same active rules as above). If not found, the delegate gets empty permissions.
  2. Read delegation_scope.base and collect delegation_scope.exception as the exception set.
  3. Start from the delegator’s own full permissions and attach a delegation block ({ delegationId, scope, exceptions }) to the resolved permissions.
  4. Administration: all system permissions are inherited when allow_administration contains ALLOWED. Otherwise system is emptied, except Since 1.10 for an ALLOW_ALL delegation with no exceptions, which keeps the System grants below Admin and drops only System Admin. Module and entity permissions are always kept.
  5. Views, pages and reports are filtered against the exceptions:
    • DENY_ALL with no exceptions: no views, pages or reports.
    • ALLOW_ALL with no exceptions: all of the delegator’s views, pages and reports.
    • With exceptions, each item is matched against the exception patterns (by item id or by its parent module, plus the general patterns so:all, so:app, so:app:module). In ALLOW_ALL mode a match excludes the item; in DENY_ALL mode a match includes it.

For the request-style inbox, observer and service-catalog list endpoints, the delegation request filter narrows the query when a delegation is active. It matches specific view URLs and injects a where filter on a per-view field:

ViewAction typeFilter field
SERVICE_CATALOGSubmitvalue.relatedEntityId
Ongoing/Completed My RequestsMyRequestvalue.reference.dataEntity
Ongoing/Completed InboxInboxvalue.reference.dataEntity
Ongoing/Completed ObserverObservevalue.reference.dataEntity

The operator depends on scope: ALLOW_ALL uses nin (exclude the exception services); DENY_ALL uses inq (include only the exception services). The general exceptions so:all and so:service short-circuit this: under ALLOW_ALL they mean “no filter”, under DENY_ALL they mean “exclude all”. The filter applies to /entries and /count.

With forward_notifications and/or forward_emails on, the delegate receives a copy of what is addressed to the delegator while the delegation is active, and only for work the delegation covers. Forwarded sources are the Send Notification and Send Email reaction actions and, for email, scheduled report deliveries. Each message is attributed to the service, module, report or view it concerns, and the scope is applied to that attribution (Allow All: sent unless excluded; Deny All: sent only when an exception grants that service, module or report, or one of the entity’s views; a message tied to one specific view needs that view granted). Skipped: a missing or deactivated delegate, the delegator themselves, the same delegator–delegate pair counted twice, and, for notifications, a delegate who is already a direct recipient. A copy is never forwarded again. If the delegates cannot be worked out, forwarding is skipped and logged, and the original delivery always goes ahead. Notification-side detail: Notification configuration.

Both public endpoints require an authenticated user (OAuth2 introspection) and live in the data service’s delegations controller.

Returns a single delegation projected to MyDelegationsDto, used by the gateway’s user-delegation plugin:

FieldTypeNotes
idstringDelegation entry id.
delegatorreferenceThe delegating user.
from_datedate-timeStart of the window.
to_datedate-time | nullEnd of the window (nullable).
delegated_toreferenceThe delegate. Since 1.4, needed for delegatee binding.

The projection omits is_active and delegation_scope.

Returns the current user’s active delegations (where they are the delegate), as an array of MyDelegationsDto. Only delegations that pass the full active check are returned, de-duplicated per delegator.

GET /v1/users/{userId}/delegation/{delegationId}/profile returns the delegated user profile. It validates that the delegation is active and resolves the delegate from delegated_to; a missing or inactive delegation yields 404 Delegation not found. It is consumed by the osos-access gateway plugin, not by end users.

Creating, editing and archiving delegations uses the generic data-entry endpoints on the delegation entity. See Writing data.

The user-delegation plugin is configured globally in config/kong.yml:

ConfigTypeRequiredDefaultPurpose
data_service_urlstringyes—Base URL of the data service used to fetch delegation details.
shared_keystringyes—Internal shared key sent as X-SHARED-KEY.
cache_ttlnumberno600Redis TTL (seconds) for cached delegation details.
redis.urlstringnoredis://localhost:6379Redis connection URL.
redis.sslbooleannofalseEnable TLS to Redis.
redis.ssl_verifybooleannofalseVerify the Redis server certificate.
redis.useSentinelbooleannofalseUse Redis Sentinel instead of a standalone server.
redis.sentinel.sentinels[]array of {host, port}——Sentinel endpoints.
redis.sentinel.username / password / masterNamestring——Sentinel auth and master name.
envPrefixstringno—Prefix prepended to Redis cache keys (per-environment namespacing).

Every action performed under a delegation is completed in the name of the delegator, while OSOS records that the real actor is the delegate, so the audit trail can always tell them apart. Delegation identifiers are attached to every workflow and comment request; the delegate’s identifier (x-delegatee-id, with x-is-delegation: true) is passed to the services for auditing. See Monitoring, logs & audit and, for the record level, Timeline.

Button-click history is attributed to the delegate Since 1.8. Before this fix, clicking a system button while acting under a delegation stamped the resulting ButtonClickedHistory record with an empty actor: delegatee was dropped because the controller handling the click never passed it to the history-creation call, although the gateway had already resolved and forwarded it. Value changes and owner reassignments made under a delegation were never affected.

  • Caching. The gateway caches delegation details for cache_ttl (600 s by default) and refetches only on a miss. When a delegation entry is edited or archived, the data service deletes the gateway’s cached copy, so the change applies at the next request. Since 1.8 it deletes both key generations, the current osos:delegation:v2: key and the older osos:delegation: key, so a cell running gateways of both generations during a rolling upgrade is covered; before, an edited or archived delegation could stay usable at a newer gateway for up to cache_ttl.
  • Delegated permissions follow permission changes Since 1.4. A delegate’s cached delegated permissions (kept up to 300 s) are cleared together with the access-right, view and report changes they embed, so a permission revoked from the delegator no longer lingers for the delegate.
  • Split enforcement. The gateway validates the delegate binding and the time window and performs the identity swap; is_active, state and delegation_scope are enforced by the data service.
  • Open-ended delegations. A null to_date never expires on its own; end it by setting is_active to INACTIVE, archiving the entry, or setting a to_date.
  • Identity downstream. Under an active delegation, downstream services see x-user-id = the delegator, with x-delegatee-id and x-is-delegation: true carrying the real caller and the flag.
  • Guest (anonymous) users have no delegations.
  • API tokens are a separate mechanism for external systems, not people. See API tokens.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27