feat(exousia): live JWT secret/TTL via config reload with immediate rotation (#529 step 3) - #583
Merged
Conversation
…otation (#529) Gate-Passed: kanon 0.1.5 +stages:fmt,check,clippy,nextest,lint sha:f744a4776cc3ffadd111e57b42f55236fd96dbd1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 3 of the #529 reactive-config migration — live JWT with immediate rotation (operator-locked semantics).
ExousiaServiceImplstored a frozenExousiaConfigcaptured at construction, so ajwt_secretor TTL change via SIGHUP had no effect until restart. It now holdshorismos::Section<ExousiaConfig>and takes exactly oneself.config.get()snapshot at the top of each operation (login,refresh,validate_bearer), using that single snapshot for both the secret and the TTLs — a torn-config guard so a mid-rotation login can never mint with secret A but TTL B.Rotation semantics (immediate, no dual-secret grace):
exousia.jwt_secret(secrets.toml orHARMONIA__EXOUSIA__JWT_SECRET) + SIGHUP. Reload validation still enforces ≥32 bytes / non-placeholder, so an invalid rotation is rejected atomically and the old secret stays in force.validate_bearerchecks HS256 against the current secret, so every in-flight access token signed with the old secret fails immediately →TokenInvalid→ HTTP 401UNAUTHORIZED. This is deliberate — rotating a compromised secret must kill outstanding bearers at once.jwt_secret), so the refresh transaction still verifies and mints the next access token under the new secret. A client that refreshes on 401 recovers without re-login.expis baked into claims at mint; a TTL change affects only tokens/refresh-rows created after the reload. Already-issued expirations are honored.exousia.jwt_secretlogswarn!("exousia.jwt_secret rotated — all outstanding access tokens are now invalid").Production wiring passes
config_handle.section(|c| &c.exousia); all 10 test/static constructors useSection::fixed(...).Client-contract follow-up (out of scope): clients that auto-refresh only on
TOKEN_EXPIREDwill treat a rotation'sUNAUTHORIZEDas logout — the desktop/theatron 401 handling should refresh on any 401 with a valid refresh token. Tracked separately.Gate:
kanon gate --fullgreen — fmt, check, clippy (-D warnings), nextest 1969 passed, deny, lint (0/0). 5 new tests (all on a liveConfigManager/Sectionpair): old-token-invalidated-immediately, refresh-across-rotation, TTL-mint-forward, middleware 401-UNAUTHORIZED, and a full-router archon integration test.Gate-Passedstamped.Refs #529