myxce/src/docs
lei.chen 9dbb75adb3 apiserver: persist API keys across restarts via state file
API keys were a pure in-memory map (store/apikey.go) — every apiserver
restart silently revoked every service-account key (advisor, MCP
server) until re-issued, with only an inexplicable 401 to show for it.

Keys now persist to <top>/state/apikeys.json: hash → metadata only
(never the raw key, preserving the existing "a dump cannot leak usable
credentials" property), written atomically (temp file + fsync + rename,
0600) on each issuance, loaded at InitStores. The load also restores
the user→role mapping, without which a reloaded key would authenticate
but be denied every permission check. A missing file is a normal fresh
install; a corrupt one fails fast at startup instead of quietly
starting with zero keys. A failed save fails the issuance request —
the raw key is shown exactly once, so we must not hand out a key we
could not persist.

The memory-only path (no SetAPIKeyStatePath) is kept for unit tests.

Cluster-verified on t1-t3: issue key → restart apiserver → key still
authenticates (hosts OK, advisor:report POST published 1) — previously
impossible. Verify job submitted, ran, exited; all daemons healthy.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-20 03:12:13 +00:00
..
archive update documents 2026-08-10 17:51:51 +08:00
advisor-demo-cases.md apiserver: persist API keys across restarts via state file 2026-10-20 03:12:13 +00:00
advisor-design.md apiserver: persist API keys across restarts via state file 2026-10-20 03:12:13 +00:00
apiserver-backend-tasks.md feat(eliminate-frontend-makefile): task 3.3 - update live documentation (11 files) 2026-09-03 14:22:54 +00:00
chatbot-verification.md fix(configs): add worker-builtin load indices missing from resources.yaml 2026-08-02 07:36:03 +00:00
claude-code-demo-guide.md fix(schedulerclient): node memory_bytes_total no longer ×1e6 (bug-1514) 2026-08-22 14:58:56 +00:00
config-replication-design.md update documents 2026-08-10 17:51:51 +08:00
config-replication-impl-status.md update documents 2026-08-10 17:51:51 +08:00
deployment.md docs: document graceful job kill/stop and job.terminate_interval (bug-1957) 2026-10-10 10:07:42 +00:00
FUTURE_WORK.md update documents 2026-08-10 17:51:51 +08:00
mcp-demo-design.md fix(schedulerclient): node memory_bytes_total no longer ×1e6 (bug-1514) 2026-08-22 14:58:56 +00:00
mcp-demo-run.py fix(schedulerclient): node memory_bytes_total no longer ×1e6 (bug-1514) 2026-08-22 14:58:56 +00:00
p1-2-host-select.md update documents 2026-08-10 17:51:51 +08:00
persistence-and-ha-design.md update documents 2026-08-10 17:51:51 +08:00
resreq-ast-cse-design.md update documents 2026-08-10 17:51:51 +08:00
xce.md feat(xcecli): jobs kill --signal and --force 2026-10-10 10:25:23 +00:00