Skip to content

fix(ateclient): auto-refresh the ateapi bearer token - #694

Open
Kyosuke Konishi (konippi) wants to merge 1 commit into
agent-substrate:mainfrom
konippi:ateclient-refresh-bearer-token
Open

fix(ateclient): auto-refresh the ateapi bearer token#694
Kyosuke Konishi (konippi) wants to merge 1 commit into
agent-substrate:mainfrom
konippi:ateclient-refresh-bearer-token

Conversation

@konippi

Copy link
Copy Markdown
Contributor

Fixes #644

internal/ateclient minted a single 1-hour ServiceAccount token at dial time and never re-minted it, so any client outliving the token failed every RPC with Unauthenticated: invalid bearer token: jwt has expired until a full reconnect.

This replaces the static string credential with a refreshing credentials.PerRPCCredentials backed by the TokenRequest API: the cached token is served while a background refresh starts at 80% of the remaining lifetime (kubelet's threshold, with a per-token 0-10s jitter), tokens stop being used 30s before issuer expiry to cover RPC transit and clock skew, concurrent callers share a single in-flight refresh that is detached from the initiating caller's cancellation and bounded by a 10s timeout, and refresh failures fall back to the still-usable old token with 1s..30s jittered exponential backoff — an expired token is never sent (fail closed). Token values never appear in errors or logs, and RequireTransportSecurity stays true.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

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.

[P1] ateclient mints a single 1-hour bearer token and never refreshes it — long-lived clients go permanently Unauthenticated

1 participant