fix token
This commit is contained in:
parent
41cfb91d4e
commit
b1f02f46f3
@ -9,7 +9,7 @@ from config import settings
|
|||||||
from .validators import validate_username as core_validate_username, validate_password as core_validate_password
|
from .validators import validate_username as core_validate_username, validate_password as core_validate_password
|
||||||
from common_lib.utils.http_client import client
|
from common_lib.utils.http_client import client
|
||||||
|
|
||||||
auth_scheme = HTTPBearer()
|
auth_scheme = HTTPBearer(auto_error=False)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -175,8 +175,8 @@ async def get_current_user(
|
|||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
detail="Authentication required: provide token in Authorization header or cookie"
|
detail="Not authenticated"
|
||||||
)
|
)
|
||||||
|
|
||||||
return await _fetch_current_user(request, token, require_permissions=False, is_web=is_web)
|
return await _fetch_current_user(request, token, require_permissions=False, is_web=is_web)
|
||||||
@ -184,7 +184,7 @@ async def get_current_user(
|
|||||||
|
|
||||||
async def get_current_user_with_permissions(
|
async def get_current_user_with_permissions(
|
||||||
request: Request,
|
request: Request,
|
||||||
credentials: HTTPAuthorizationCredentials = Depends(auth_scheme)
|
credentials: Optional[HTTPAuthorizationCredentials] = Depends(auth_scheme)
|
||||||
) -> CurrentUser:
|
) -> CurrentUser:
|
||||||
token = None
|
token = None
|
||||||
|
|
||||||
@ -197,8 +197,8 @@ async def get_current_user_with_permissions(
|
|||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
detail="Authentication required: provide token in Authorization header or cookie"
|
detail="Not authenticated"
|
||||||
)
|
)
|
||||||
|
|
||||||
return await _fetch_current_user(request, token, require_permissions=True)
|
return await _fetch_current_user(request, token, require_permissions=True)
|
||||||
@ -207,7 +207,7 @@ async def get_current_user_with_permissions(
|
|||||||
async def get_current_user_or_bot(
|
async def get_current_user_or_bot(
|
||||||
request: Request,
|
request: Request,
|
||||||
is_bot: str | None = Header(default=None),
|
is_bot: str | None = Header(default=None),
|
||||||
credentials: HTTPAuthorizationCredentials = Depends(auth_scheme)
|
credentials: Optional[HTTPAuthorizationCredentials] = Depends(auth_scheme)
|
||||||
) -> CurrentUser:
|
) -> CurrentUser:
|
||||||
token = None
|
token = None
|
||||||
|
|
||||||
@ -220,8 +220,8 @@ async def get_current_user_or_bot(
|
|||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
detail="Authentication required: provide token in Authorization header or cookie"
|
detail="Not authenticated"
|
||||||
)
|
)
|
||||||
|
|
||||||
is_bot_flag = str(is_bot).lower() in ("true", "1", "yes") if is_bot else False
|
is_bot_flag = str(is_bot).lower() in ("true", "1", "yes") if is_bot else False
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "common-lib"
|
name = "common-lib"
|
||||||
version = "0.0.46"
|
version = "0.0.47"
|
||||||
description = "Библиотека общих компонентов для микросервисов yobble"
|
description = "Библиотека общих компонентов для микросервисов yobble"
|
||||||
authors = [{ name = "cheykrym", email = "you@example.com" }]
|
authors = [{ name = "cheykrym", email = "you@example.com" }]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user