Skip to content

Parity with aiohttp#343

Merged
axelsrz merged 1 commit intomainfrom
users/axsuarez/fast-api-jwt-middleware-fix
Mar 27, 2026
Merged

Parity with aiohttp#343
axelsrz merged 1 commit intomainfrom
users/axsuarez/fast-api-jwt-middleware-fix

Conversation

@axelsrz
Copy link
Copy Markdown
Member

@axelsrz axelsrz commented Mar 27, 2026

This pull request updates the JWT authorization middleware to improve how anonymous access is handled. Now, the middleware checks if anonymous access is allowed via the ANONYMOUS_ALLOWED configuration flag, rather than relying on the presence of CLIENT_ID.

Authorization logic update:

  • Changed the conditional in jwt_authorization_middleware.py so that anonymous claims are granted if auth_config.ANONYMOUS_ALLOWED is true, instead of checking for a missing CLIENT_ID.

@axelsrz axelsrz requested a review from MattB-msft March 27, 2026 00:06
@axelsrz axelsrz requested a review from a team as a code owner March 27, 2026 00:06
Copilot AI review requested due to automatic review settings March 27, 2026 00:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the FastAPI JWT authorization middleware to align anonymous access behavior with the configuration flag (ANONYMOUS_ALLOWED) rather than inferring it from CLIENT_ID presence, bringing it closer to the aiohttp middleware behavior.

Changes:

  • Switch anonymous-claims gating to auth_config.ANONYMOUS_ALLOWED when no Authorization header is provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@axelsrz axelsrz merged commit cca9764 into main Mar 27, 2026
14 checks passed
@axelsrz axelsrz deleted the users/axsuarez/fast-api-jwt-middleware-fix branch March 27, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants