-
Notifications
You must be signed in to change notification settings - Fork 56
Fix: Remove await from synchronous get_anonymous_claims() in FastAPI JWT middleware #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: MattB-msft <10568244+MattB-msft@users.noreply.github.com>
Co-authored-by: MattB-msft <10568244+MattB-msft@users.noreply.github.com>
|
@copilot run the python command black on the folder containing any files you modify, and accept those changes. |
Black has been run on both |
|
@copilot remove the tests you added |
Co-authored-by: MattB-msft <10568244+MattB-msft@users.noreply.github.com>
|
@copilot Add Tests back to this PR, Add the tests to the test_samples/fastapi folder in the project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a runtime error in the FastAPI JWT authorization middleware by correctly treating get_anonymous_claims() as a synchronous method, aligning the behavior with the aiohttp middleware.
Changes:
- Updated
JwtAuthorizationMiddlewareto callJwtTokenValidator.get_anonymous_claims()withoutawaitwhen handling anonymous access (noAuthorizationheader and noCLIENT_IDconfigured).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
FastAPI JWT middleware was incorrectly awaiting
get_anonymous_claims(), a synchronous method, causing runtime errors in anonymous mode.Changes
Fixed middleware (
jwt_authorization_middleware.pyline 65)The method signature in
JwtTokenValidatoris:This aligns with the aiohttp middleware implementation which correctly calls it synchronously.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.