fix(oauth): preserve existing refresh_token when refresh response omits it#2271
Open
oedokumaci wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
fix(oauth): preserve existing refresh_token when refresh response omits it#2271oedokumaci wants to merge 1 commit intomodelcontextprotocol:mainfrom
oedokumaci wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
6758180 to
ae5050b
Compare
2 tasks
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.
Fixes #2270
Per RFC 6749 Section 6, the authorization server MAY issue a new refresh token in the refresh response. When it doesn't,
_handle_refresh_responseoverwrites the stored token as-is, discarding the existingrefresh_token. After the first successful refresh,can_refresh_token()returnsFalseand subsequent refreshes fail.This preserves the existing
refresh_tokenwhen the response omits one, usingmodel_copy(update=...).Also removes
# pragma: no coverfrom_handle_refresh_response(added in a bulk coverage baseline, not intentional) and adds tests covering all branches: success with preservation, success with rotation, no prior tokens, non-200 failure, and invalid JSON.Note: #2270 hasn't received the
ready for worklabel yet. Submitting this early since the fix is small and self-contained. Happy to wait or adjust based on maintainer feedback.