(self, scope: Scope, receive: Receive, send: Send)
| 27 | ) |
| 28 | |
| 29 | async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: |
| 30 | if scope["type"] not in ["http", "websocket"]: |
| 31 | await self.app(scope, receive, send) |
| 32 | return |
| 33 | |
| 34 | conn = HTTPConnection(scope) |
| 35 | try: |
| 36 | auth_result = await self.backend.authenticate(conn) |
| 37 | except AuthenticationError as exc: |
| 38 | response = self.on_error(conn, exc) |
| 39 | if scope["type"] == "websocket": |
| 40 | await send({"type": "websocket.close", "code": 1000}) |
| 41 | else: |
| 42 | await response(scope, receive, send) |
| 43 | return |
| 44 | |
| 45 | if auth_result is None: |
| 46 | auth_result = AuthCredentials(), UnauthenticatedUser() |
| 47 | scope["auth"], scope["user"] = auth_result |
| 48 | await self.app(scope, receive, send) |
| 49 | |
| 50 | @staticmethod |
| 51 | def default_on_error(conn: HTTPConnection, exc: Exception) -> Response: |
nothing calls this directly
no test coverage detected