ADR 0017: authentication and trust boundary
Status: Accepted on 2026-11-29 (knotrel/knotrel#224). Scope decisions Q8 and Q9 approved by the maintainer on 2026-11-29. Issues: #185 (native authentication and untrusted exposure), #223 (native TLS and mTLS, backlog), #155 (tenant-scoped authorization).
Related: threat model, ADR 0015 (runtime and registry).
Context
Knotrel has no authentication, authorization or TLS of its own. The supported exposures are loopback (E1), a fully trusted network (E2) and a gateway that terminates TLS and authenticates every request (E3); untrusted exposure (E4) is not supported. Feeder takeover is mitigated only by the boundary (G3).
Multi-tenant graphs (ADR 0015) need to know which tenant a request belongs to, and that identity must come from a trusted source, never from what the client claims.
Decision
- Authentication is an optional extension of
knotrel-server, defined by two traits: an authenticator that turns a request into a principal (subject, tenant, roles) before admission, and an authorizer that decides an action (probe, metrics, read, inspect, mutate, feeder control, feeder data, import, graph admin, tenant admin) on a resource (the server or one graph). The default keeps today’s behavior: every request is the local principal, and E1–E3 stay the supported exposures. - Q9: the first implementation trusts a verified identity from the gateway. The gateway authenticates the client by any means it supports and forwards the identity in a fixed set of headers. Static tokens and JWT/OIDC are later implementations of the same traits.
- Two conditions keep a client from forging an identity. Both are
deployment requirements, stated as such in the deployment documentation:
- The gateway strips or overwrites every identity header the client sent, on every forwarded request. A gateway that only adds headers when it authenticates someone lets any client forge an identity.
- Only the gateway can reach the listener that trusts those headers (loopback in a namespace shared only with the gateway, a Unix socket, or a network policy). A client that connects directly can send any identity.
The gateway-identity authenticator is off by default, and the startup log states these conditions when it is enabled.
- Q8: in v1.3.0 TLS and mTLS terminate at the gateway. A client certificate identity exists only at the gateway, which forwards it as a verified identity. Native TLS and mTLS in the server, with certificate identity mapped to a principal by one more authenticator implementation, are evaluated in #223.
- E4 stays unsupported even with an extension installed, until the abuse tests of #185 (rate limits, resource bounds, audit) exist.
Alternatives considered
- Mandatory built-in authentication. Breaks every existing E1–E3 deployment and duplicates what gateways already do. Rejected.
- Static tokens first. Closes feeder takeover on a trusted network without a gateway, but needs token storage and rotation and, off loopback, TLS on the path. Kept as the second implementation.
- JWT/OIDC first. Standard for identity providers, but adds a JWT and key set dependency and clock and rotation handling. Later, behind a Cargo feature.
- Native TLS and mTLS in v1.3.0. Needed only where no gateway or mesh can be used; adds a TLS stack, certificate rotation and revocation to the server. Deferred to #223 (Q8).
- Token introspection on every request. Couples every request to a remote service. Rejected.
Consequences
- One mechanism serves both the optional authentication of #185 and the tenant scoping of #155; certificate identity, if adopted, is a further implementation, not a second mechanism.
- The threat model gains a boundary for identity headers, with the threats “forged identity header” and “gateway bypass” and their validations: headers ignored while the extension is off, and a gateway smoke-test check that a client-supplied identity header never reaches Knotrel.
- Optional defense in depth (a peer allowlist or a gateway-signed header) is settled in the implementation of #185 and does not replace the two conditions.
- Failures answer 401 or 403 with the standard error envelope and never echo credentials.