Skip to content

Update HTTPBearer to return 401 on error#10232

Closed
ordinary-jamie wants to merge 1 commit intofastapi:masterfrom
ordinary-jamie:bug/http-bearer-4xx-code
Closed

Update HTTPBearer to return 401 on error#10232
ordinary-jamie wants to merge 1 commit intofastapi:masterfrom
ordinary-jamie:bug/http-bearer-4xx-code

Conversation

@ordinary-jamie
Copy link
Contributor

@ordinary-jamie ordinary-jamie commented Sep 12, 2023

🎯 Aim

Closes #10177

📋Notes

RFC 6750 section 3.1 suggests that for cases where the "...access token provided is expired, revoked, malformed, or invalid for other reasons. The resource SHOULD respond with the HTTP 401 (Unauthorized) status code."

This commit updates the HTTPBearer scheme to reflect this.

HTTPBearer scheme should return a 401 in the case of missing or
malformed authorization header, consistent with RFC 6750 Section 3.1
@Kludex
Copy link
Member

Kludex commented Sep 12, 2023

@ordinary-jamie
Copy link
Contributor Author

Ah woops, sorry didn't properly check first

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.

HTTPBearer security scheme is returning 403 instead or 401

2 participants