Repository navigation
Refresh expired token in AuthClient calls - #126
Merged
Merged
Conversation
AuthClient called the tonic stub directly, so with auto token refresh enabled an expired token still failed role_*/user_*/auth_enable/ auth_disable with Unauthenticated, unlike every other client. ClientCaller used an AuthClient to authenticate, which made it impossible for AuthClient to use a ClientCaller. Make ClientCaller authenticate with the raw auth stub instead, and route every AuthClient method except authenticate through do_call. authenticate stays raw since it is the call that obtains a token. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Summary
AuthClientcalled the tonic stub directly, so it skipped the token refresh every other client gets fromClientCaller::do_call. It could not useClientCallerbecauseClientCallerheld anAuthClientto authenticate.ClientCallernow authenticates with the raw stub, which breaks the cycle.Evidence
with_auto_token_refresh(true),user_list()after the token expired (etcd 3.7.2,ETCD_AUTH_TOKEN_TTL=2):test_auth_refresh_tokenpasses. It now also callsuser_list()andauth_client().role_list()after the token expired.cargo testandcargo clippy --all-targets -D warningspass locally on 3.7.2.Merge Danger
Door: two-way
Blast Radius:
AuthClientAuthClient::newnow takes aClientCallerBuilder. It ispub(crate), so there is no public API change. Auth calls only retry whenwith_auto_token_refresh(true)is set and credentials exist, same as the other clients. Not tested on etcd 3.5 / 3.6 or a multi-node cluster; CI covers those.🤖 Generated with Claude Code