Does: turns a credential into an identity. The token store, the per-start admin secret, the socket hello check, the uplink join-token check and the HTTP request check live here and nowhere else.
Strategies (ADR 0033):
authenticateRequestasks the enabled strategies in registry order (strategies/index.ts):token, thenproxy, so a goodslk_token wins. The first answer other thannot-mineends the list, and the refusal's message and details come from the strategy.not-minemeans the strategy's credential is absent. It is not a refusal: the next strategy is asked.strategies/conformance.test.tsruns every registered strategy:not-minewithout its credential,viaequal to its name.
The proxy strategy:
- With
header: authorization, only aBearervalue that does not startslk_is its credential. - A credential over
HEADER_MAX_LENGTH(strategies/proxy-jwt/index.ts) ismalformed, and nothing is fetched for it. - A verified JWT with no person claims is
not-mine, not a refusal. - A refusal is one
warnlog line with the reason and jose's message, never the JWT. - A proxy identity is
ambientand carriesexpiresAt: http's cross-site check and the stream deadlines read them. KeyCacheis ours, not jose's remote set, so it runs on theClock.- It fails closed: a failed fetch keeps the keys while they are younger than
KEY_KEEP_MS(strategies/proxy-jwt/key-cache.ts); past that they are dropped and every proxy JWT iskeys-unavailableuntil a fetch works. - An unknown key id refetches at most once per
UNKNOWN_KEY_REFETCH_MS, counted from the last good fetch. - The fetch goes through the
KeySetFetcherport, which never follows a redirect and caps the body.
Tokens and the uplink:
- A worker join token is
forbiddenon HTTP and accepted only byauthenticateUplink. - The claimed worker id is checked against the id alphabet before any pin, so
*,.,..and an empty id never reach the store. - A join token is pinned to the first worker id it is accepted with, and a worker id to one live token. Re-pairing is
token revoke+token create. - Every verify reads the
tokenstable, so atoken revoketakes effect at once. createAuthtakes the daemon'sSqliteDatabase, never the state module.
Socket:
- At
hello, no credential isagent. A credential that is neither an operator token nor the admin secret isAdminAuthenticationFailedError, never a quietagent. - The admin secret's hash lives in memory from construction; the plaintext is written to
admin.tokenonly bypersist, which the daemon calls after the socket claim.
- A directory under
strategies/, and one line instrategies/index.ts: its place in the list is its priority. - A fixture in
strategies/conformance.test.ts. - If it owns a config key under
http: the mirror in the contract'sconfigSchema.src/core/config.tsvalidates and defaults the key from the definition.