Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions fastapi/security/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,11 @@ async def __call__(
else:
return None
if scheme.lower() != "digest":
raise HTTPException(
status_code=HTTP_403_FORBIDDEN,
detail="Invalid authentication credentials",
)
if self.auto_error:
raise HTTPException(
status_code=HTTP_403_FORBIDDEN,
detail="Invalid authentication credentials",
)
else:
Comment thread
svlandeg marked this conversation as resolved.
return None
return HTTPAuthorizationCredentials(scheme=scheme, credentials=credentials)
4 changes: 2 additions & 2 deletions tests/test_security_http_digest_optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def test_security_http_digest_incorrect_scheme_credentials():
response = client.get(
"/users/me", headers={"Authorization": "Other invalidauthorization"}
)
assert response.status_code == 403, response.text
Comment thread
svlandeg marked this conversation as resolved.
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}


def test_openapi_schema():
Expand Down