The security boundary
Section titled “The security boundary”This page describes a real trust boundary in the OSOS platform’s architecture, not a vulnerability. Understanding it correctly is what lets an operator deploy the platform safely and a client author reason about what their code may and may not hold. The short version: authentication happens once, at the gateway. Everything behind the gateway trusts identity headers. Get the boundary right and the design is sound; expose a service past the gateway and the same design becomes an open door.
Where tokens are checked, and where they are not
Section titled “Where tokens are checked, and where they are not”An external caller presents a bearer token (OAuth 2.0 / OIDC) or an application token. That credential is validated at the edge — the gateway’s oauth2-introspection and app-token-auth plugins do the validation (api-gateway/kong/plugins/).
Downstream services do not re-validate the token. They never see it. A LoopBack service’s authentication strategy resolves the caller’s identity entirely from request headers that the gateway sets after it has authenticated the caller, and it authorises the request only when a valid preshared key accompanies those headers. There is no second, independent check of the original token behind the gateway. This is a deliberate performance and separation-of-concerns choice — the edge authenticates, the services authorise — and it is correct as long as nothing can reach a service except through the edge.
The identity headers services trust
Section titled “The identity headers services trust”After the gateway authenticates a caller, it forwards identity as a set of headers. The service’s strategy reads them directly:
| Header | Meaning |
|---|---|
x-shared-key | The preshared trust key between gateway and service. The request resolves to a user profile only if this matches the service’s configured key. |
x-user-id | The authenticated subject. The loaded profile, roles and permissions are all derived from this id. |
x-space-id | The tenant / space. The same operation returns different data per space. |
x-client-id | The OAuth client id of the caller. |
x-is-delegation, x-delegatee-id, x-delegation-id | Act-on-behalf-of (delegation) context. |
x-service | The calling service’s name. A service can treat API Gateway here as proof that the request came through the gateway. |
x-view-id | The view the request is made through. A service authorises a request carrying it as made through that view. |
The consequence is the whole of this page: to a downstream service, identity is whatever these headers say it is. A request that arrives carrying x-shared-key set to the service’s key and x-user-id set to any user’s id is, as far as that service is concerned, that user — with that user’s full permissions, in the space named by x-space-id. No token is required, because tokens are an edge concern. This is exactly why the boundary must never be exposed: the header pair x-shared-key + x-user-id is sufficient to act as anyone.
How the gateway protects the headers
Section titled “How the gateway protects the headers”The design is safe because the gateway makes those headers un-spoofable from the outside. Three mechanisms do this, and understanding them is what makes the deployment rule below non-negotiable.
The shared key is stripped and re-injected
Section titled “The shared key is stripped and re-injected”The gateway removes any client-supplied x-shared-key from every inbound request and then re-adds the correct value itself (request-transformer plugin in config/kong.yml). Crucially, it only injects the real key when the request authenticated: an unauthenticated request has its identity headers cleared and a marker set, so the value re-injected as x-shared-key is a placeholder rather than the real key, and the downstream service — seeing a key that does not match its configured one — resolves to no user and rejects the call (checkSharedKey). A caller therefore cannot smuggle in a valid shared key, and cannot obtain one by simply omitting a token.
Identity headers are cleared and re-set from the validated token
Section titled “Identity headers are cleared and re-set from the validated token”The oauth2-introspection plugin clears x-user-id, x-client-id and x-session-id on every request and re-sets them from the introspected token’s own claims. A client-supplied x-user-id is discarded before it can be trusted; the id that reaches the service is the one the token actually authenticated as. The application-token plugin behaves the same way, setting x-user-id from the validated token’s application user. So the identity a service receives is always the gateway’s word, derived from a credential it checked — never the client’s assertion.
Service and view headers are removed too Since 1.10
Section titled “Service and view headers are removed too Since 1.10”The same request-transformer step also removes, new in 1.10, a client-supplied x-service, which it then sets to API Gateway itself — before the fix, a client’s own x-service survived, because the plugin only adds a header that is absent. And the osos-access plugin now clears a client-supplied x-view-id before it checks anything, setting it again only from the {viewId} of a /api/v1/v/{viewId}/… path once the view-access checks pass; before the fix a client could send x-view-id on any route and be authorised as if it had come through that view. The x-service strip is in the chart’s gateway configuration and works with any gateway image; the x-view-id clear needs a gateway image built after api-gateway 2.6.11. The full table is in Calling the HTTP API.
The deployment rule
Section titled “The deployment rule”Everything above holds on one condition, and it is the single most important operational fact on this page:
A downstream service port must never be reachable except through the gateway.
Firewall every service so that only the gateway can connect to it. The headers that carry identity — above all x-shared-key, x-user-id, x-space-id, x-service and x-view-id, and every other internal header the gateway sets — are trusted implicitly by the service. If any network path lets a caller reach a service directly, that caller can set those headers itself and impersonate any user in any space, bypassing authentication entirely. The gateway’s stripping and re-injection protect requests that go through it; they protect nothing about a request that goes around it. Name these headers in your network policy and block them at any ingress that is not the gateway.
What a client may hold, and what stays server-side
Section titled “What a client may hold, and what stays server-side”The boundary defines a clean split of what belongs where.
A client legitimately holds only:
- its base URL (the gateway host);
- its credential — a bearer token, or an application token sent as
x-app-token.
A client must never hold or set:
- the shared key (
x-shared-key) — it is the gateway↔service trust secret and lives only server-side (SHARED_KEY; see Environments and promotion); - any identity header —
x-user-id,x-space-id,x-client-id,x-service,x-view-id, and any other internal header. These are the gateway’s to set from the validated credential and the request path. A client that sets them is either being ignored (through the gateway, they are overwritten) or is talking to an exposed service (around the gateway, they are a breach).
If you find client code setting x-shared-key or x-user-id, that is the signal to stop: either it is dead code, or it is evidence that a service is reachable off-gateway.
Delegation
Section titled “Delegation”Delegation lets a request act as someone other than the immediate caller, and it is strictly gateway-mediated for the same reason as the rest.
Delegation (x-is-delegation, x-delegatee-id, x-delegation-id) lets a caller act on behalf of another user, with an audit trail. The client names the delegation with x-delegation-id; the gateway’s user-delegation plugin validates the delegation record — that it exists, that the caller is its delegatee, and that the current time falls within its active window — and on a validated delegation sets x-delegatee-id to the caller, rewrites x-user-id to the delegator and sets x-is-delegation: true. A delegation that belongs to another user, or is expired or not yet active, is rejected at the edge with a 403.
Summary
Section titled “Summary”- The gateway authenticates; services authorise from trusted headers. Tokens are never re-checked downstream.
x-shared-key+x-user-idis sufficient to impersonate any user — to a service, identity is whatever the headers say.- The gateway strips client-supplied
x-shared-keyand identity headers and re-injects them from the validated credential, which is what makes the design safe.Since 1.10it also strips a client’sx-serviceand clears itsx-view-id. - That safety depends entirely on services being unreachable except through the gateway. Firewall the identity headers at every non-gateway ingress.
- A client holds a base URL and a credential — nothing else. The shared key and all identity headers stay server-side.
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