Browse Source
Authorization: Bearer (empty token after "Bearer") was returned as "" instead of triggering the auto_error path. Both OAuth2PasswordBearer and OAuth2AuthorizationCodeBearer only checked that the scheme was "bearer" but not that the credential string was non-empty. RFC 6750 Section 2.1 defines b64token = 1*(...) — at least one character required. An empty credential is syntactically malformed and should be treated the same as missing credentials: 401 with auto_error=True, None with auto_error=False. Fix: add `not param` to the guard condition in both __call__ methods. Closes: https://github.com/fastapi/fastapi/discussions/15192pull/15220/head
3 changed files with 14 additions and 2 deletions
Loading…
Reference in new issue