( # type: ignore
self, request: Request
)
| 200 | return {"WWW-Authenticate": "Basic"} |
| 201 | |
| 202 | async def __call__( # type: ignore |
| 203 | self, request: Request |
| 204 | ) -> HTTPBasicCredentials | None: |
| 205 | authorization = request.headers.get("Authorization") |
| 206 | scheme, param = get_authorization_scheme_param(authorization) |
| 207 | if not authorization or scheme.lower() != "basic": |
| 208 | if self.auto_error: |
| 209 | raise self.make_not_authenticated_error() |
| 210 | else: |
| 211 | return None |
| 212 | try: |
| 213 | data = b64decode(param).decode("ascii") |
| 214 | except (ValueError, UnicodeDecodeError, binascii.Error) as e: |
| 215 | raise self.make_not_authenticated_error() from e |
| 216 | username, separator, password = data.partition(":") |
| 217 | if not separator: |
| 218 | raise self.make_not_authenticated_error() |
| 219 | return HTTPBasicCredentials(username=username, password=password) |
| 220 | |
| 221 | |
| 222 | class HTTPBearer(HTTPBase): |
nothing calls this directly
no test coverage detected