(
self,
request: HTTPConnection,
)
| 25 | |
| 26 | class BasicAuth(AuthenticationBackend): |
| 27 | async def authenticate( |
| 28 | self, |
| 29 | request: HTTPConnection, |
| 30 | ) -> tuple[AuthCredentials, SimpleUser] | None: |
| 31 | if class="st">"Authorization" not in request.headers: |
| 32 | return None |
| 33 | |
| 34 | auth = request.headers[class="st">"Authorization"] |
| 35 | try: |
| 36 | scheme, credentials = auth.split() |
| 37 | decoded = base64.b64decode(credentials).decode(class="st">"ascii") |
| 38 | except (ValueError, UnicodeDecodeError, binascii.Error): |
| 39 | raise AuthenticationError(class="st">"Invalid basic auth credentials") |
| 40 | |
| 41 | username, _, password = decoded.partition(class="st">":") |
| 42 | return AuthCredentials([class="st">"authenticated"]), SimpleUser(username) |
| 43 | |
| 44 | |
| 45 | def homepage(request: Request) -> JSONResponse: |
nothing calls this directly
no test coverage detected