You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WithTokenFromFile / AuthTokenFile read the token once; rotated tokens are never picked up #319
networking.HttpClientBuilder.WithTokenFromFile (and therefore authn.Config.AuthTokenFile) reads the token file once, when Build() is called. A token that is rotated on disk afterwards is never picked up, so the client keeps sending the old bearer.
The doc comment on authn.Config.AuthTokenFile says the opposite: "The networking package re-reads the file per request, so a rotated token is picked up without restarting the validator."
Where
networking/http_client.go, createTokenSourceFromFile: it calls os.ReadFile once and returns oauth2.StaticTokenSource(token). Build() wraps that in an oauth2.Transport, so every later request reuses the same string.
The ToolHive operator's KubernetesServiceAccount OIDC type sets JWKSAuthTokenPath to /var/run/secrets/kubernetes.io/serviceaccount/token (cmd/thv-operator/pkg/oidc/resolver.go). Kubelet rewrites that file as the projected token rotates. A validator built from that path keeps presenting the token it read at startup. I have not tested this on a live cluster; the reproduction above is the file-level behaviour.
Suggested fix
Read the file on each request. Either:
an oauth2.TokenSource whose Token() re-reads and trims the file (not wrapped in oauth2.ReuseTokenSource, since there is no expiry to key on), or
a small RoundTripper that does the same.
Keep the current checks: an empty file is an error, and Build() can still read the file once to fail fast on a bad path. The existing SameHostRedirectPolicy handling does not need to change.
A regression test along the lines of the reproduction above would cover it.
Activity
fix(networking): reload bearer tokens from file on each request (stac…