Skip to content

feat(client): add setToken() for JWT token rotation#94

Merged
zeevdr merged 1 commit into
mainfrom
feat/token-rotation
May 25, 2026
Merged

feat(client): add setToken() for JWT token rotation#94
zeevdr merged 1 commit into
mainfrom
feat/token-rotation

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 25, 2026

Summary

  • Tokens set at construction time were frozen — clients in long-running processes could not refresh expiring JWTs without creating a new client and tearing down watchers.
  • setToken(token) mutates the shared Metadata object in place, so active ConfigWatcher instances automatically use the new token on their next reconnect with no extra wiring.
  • When called on a header-mode client (x-subject / x-role), it clears those keys and switches fully to JWT auth for all subsequent RPCs.

Test plan

  • setToken() on a header-mode client: subsequent get() sends Bearer <new-token> and clears x-subject / x-role
  • setToken() on a token-mode client: subsequent get() sends the rotated token
  • All 225 existing unit + contract tests pass

Closes #62

Adds ConfigClient.setToken(token) to allow callers to rotate bearer
tokens after construction. The method mutates the shared Metadata
object, so active ConfigWatcher instances automatically use the new
token on their next reconnect without any additional wiring.

When called on a client that was constructed in header-mode (x-subject,
x-role, x-tenant-id), setToken() removes those headers and switches
fully to JWT auth for all subsequent RPCs.

Closes #62

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr added this to the Beta Readiness milestone May 25, 2026
@zeevdr zeevdr added size: S Quick win — a few hours or less priority: P1 Current milestone work labels May 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zeevdr zeevdr enabled auto-merge (squash) May 25, 2026 15:23
@zeevdr zeevdr merged commit 6c8a4b7 into main May 25, 2026
15 checks passed
@zeevdr zeevdr deleted the feat/token-rotation branch May 25, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P1 Current milestone work size: S Quick win — a few hours or less

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Token rotation: setToken or per-call interceptor for OAuth refresh

1 participant