feat(networking): surface AuthenticationExpired for unrecoverable OAuth logins#2536
Draft
nichmor wants to merge 1 commit into
Draft
feat(networking): surface AuthenticationExpired for unrecoverable OAuth logins#2536nichmor wants to merge 1 commit into
nichmor wants to merge 1 commit into
Conversation
…th logins
When a stored OAuth credential is expired, cannot be refreshed because the
login itself is no longer usable (no refresh token, or the server says
re-authentication is required), and the resulting unauthenticated request
still comes back 401/403, return a typed AuthenticationExpired { host }
error so callers can prompt the user to log in again.
Builds on main's OAuthRefreshOutcome: reads refresh_result.failure() and
only treats MissingRefreshToken / ReauthenticationRequired as needing
re-auth, leaving transient refresh problems to log-and-continue.
Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Description
Builds on the OAuth refresh handling already in
main(OAuthRefreshOutcome/OAuthRefreshFailure, which drops an expired access token when it cannot berefreshed and sends the request unauthenticated so the auth-challenge
middleware can take over).
This adds a typed
AuthenticationExpired { host }error for the case wherethe stored login itself is no longer usable. In
AuthenticationMiddleware:refresh_result.failure()and treat onlyMissingRefreshTokenandReauthenticationRequiredas "the login is dead"(transient refresh problems keep the existing log-and-continue behavior);
unauthenticated) remember the host;
401/403, returnAuthenticationExpired { host }so callers can prompt the user tore-authenticate (e.g. re-run their login command).
AuthenticationExpiredis re-exported from the crate root.How Has This Been Tested?
pixi run cargo-fmtandpixi run -- cargo clippy -p rattler_networking --all-targetsare clean.oauth_refresh/authentication_middlewareunittests in
mainfor the refresh-outcome paths.AI Disclosure
Tools: Claude (Claude Code, Opus 4.8)
Checklist: