Реализовать observability для лабораторной 6
This commit is contained in:
+3
-2
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from fastapi import Depends, Header, HTTPException, Request, status
|
||||
from fastapi import Depends, HTTPException, Request, Security, status
|
||||
|
||||
from ..db.redis import RedisSessionStore
|
||||
from ..domain.errors import Unauthorized
|
||||
@@ -11,6 +11,7 @@ from ..services.chats import ChatService
|
||||
from ..services.attachments import AttachmentService
|
||||
from ..services.messages import MessageService
|
||||
from ..services.users import UserService
|
||||
from .security import bearer_auth
|
||||
|
||||
_BEARER_CHALLENGE = 'Bearer realm="messenger"'
|
||||
|
||||
@@ -56,7 +57,7 @@ def _bearer_error() -> HTTPException:
|
||||
)
|
||||
|
||||
|
||||
async def bearer_token(authorization: str | None = Header(None)) -> str:
|
||||
async def bearer_token(authorization: str | None = Security(bearer_auth)) -> str:
|
||||
if not authorization:
|
||||
raise _bearer_error()
|
||||
scheme, separator, token = authorization.partition(' ')
|
||||
|
||||
Reference in New Issue
Block a user