Skip to content

KTMS_READ_KEY: a read-only Keystone key for reads and viewers - #28

Merged
coyl merged 2 commits into
mainfrom
feat/read-key
Oct 24, 2026
Merged

coyl merged 2 commits into
mainfrom
feat/read-key

Conversation

@coyl

@coyl coyl commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Closes ai-process/docs#136 (epic ai-process/docs#137).

  • Optional KTMS_READ_KEY (Keystone 1.2+, scope admin:read). The gRPC interceptor picks the key per call: Admin API Get*/List*/ExplainRoute and every call made for a viewer (the guard marks the request context) go with the read key; everything else, including the playground, keeps KTMS_ADMIN_KEY. Without KTMS_READ_KEY nothing changes.
  • Health: proxy.keys reports each key — the admin key must be able to write, the read key must read and must not write. The write probe is MintAPIKey{}: Keystone checks the scope before the empty name, so the code tells the scopes apart and nothing is created. The sidebar shows a dot per key under "KTMS gateway".
  • Tests: key choice per method and for viewers, the key on the wire, health with right keys, a read key in KTMS_ADMIN_KEY, an admin key in KTMS_READ_KEY.
  • e2e: when Keystone knows admin:read (it does on main; the pinned v1.0.0 pair skips it), the console mints a read key, runs with both, reads and changes, and reports a read key used as the admin key. Run locally with KTMS_REF=main TOKENMETER_REF=main: passes.
  • README (variable table, security model), env.example, CHANGELOG.

coyl added 2 commits October 24, 2026 04:20
With the optional KTMS_READ_KEY (scope admin:read), Admin API reads and
every call of a viewer carry it, so they cannot change Keystone even if a
route's role check were wrong; changes keep KTMS_ADMIN_KEY. The sidebar
shows whether each key is accepted for its job, probing writes with an
empty MintAPIKey that fails validation after the scope check. The e2e
covers both keys when Keystone knows admin:read.
The read methods are listed, not guessed from names. Key probes run once a
minute on their own context, in parallel with light-tokenmeter's check, so
a slow gateway cannot mark it down; a probe that fails for other reasons is
not a refused key. The write probe is doubly invalid. A refused read names
KTMS_READ_KEY. The e2e proves reads carry the read key with a bogus one,
and skips only when Keystone does not know the scope.
@coyl
coyl merged commit 7ed2a0a into main Oct 24, 2026
4 checks passed
@coyl
coyl deleted the feat/read-key branch October 24, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant