feat: troppa roba davvero
This commit is contained in:
@@ -17,7 +17,10 @@ class Settings(BaseSettings):
|
||||
JWT_EXPIRE_MINUTES: int = Field(default=720, gt=0)
|
||||
AUTH_USERNAME: str
|
||||
AUTH_PASSWORD: str
|
||||
API_PORT: int = Field(default=3671, ge=1, le=65535)
|
||||
SERVICE_SCAN_ROOT: str | None = None
|
||||
HEALTHCHECK_INTERVAL_SECONDS: int = Field(default=15, ge=5, le=300)
|
||||
HEALTH_HISTORY_TTL_SECONDS: int = Field(default=86400, ge=300)
|
||||
|
||||
|
||||
settings = Settings()
|
||||
settings = Settings() # pyright: ignore[reportCallIssue]
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
from core.config import settings
|
||||
from typing import Any
|
||||
|
||||
from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorDatabase
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
class _MongoDB:
|
||||
client: AsyncIOMotorClient | None = None
|
||||
client: AsyncIOMotorClient[dict[str, Any]] | None = None
|
||||
|
||||
def get_database(self) -> AsyncIOMotorDatabase:
|
||||
def get_database(self) -> AsyncIOMotorDatabase[dict[str, Any]]:
|
||||
if self.client is None:
|
||||
raise RuntimeError("MongoDB client has not been initialized")
|
||||
return self.client[settings.MONGODB_DB_NAME]
|
||||
@@ -26,7 +29,7 @@ async def close_mongodb() -> None:
|
||||
client.close()
|
||||
|
||||
|
||||
async def get_database() -> AsyncIOMotorDatabase:
|
||||
async def get_database() -> AsyncIOMotorDatabase[dict[str, Any]]:
|
||||
return mongodb.get_database()
|
||||
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@ from uuid import uuid4
|
||||
|
||||
from authlib.jose import jwt # type: ignore
|
||||
from authlib.jose.errors import JoseError # type: ignore
|
||||
from core.config import settings
|
||||
from fastapi import Depends, HTTPException, status
|
||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
||||
from models.auth import AccessTokenPayload, AuthUserDocument
|
||||
from pwdlib import PasswordHash
|
||||
from pwdlib.hashers.argon2 import Argon2Hasher
|
||||
from repositories.auth import get_user_by_username, is_token_revoked
|
||||
|
||||
from app.core.config import settings
|
||||
from app.models.auth import AccessTokenPayload, AuthUserDocument
|
||||
from app.repositories.auth import get_user_by_username, is_token_revoked
|
||||
|
||||
pwd_context = PasswordHash((Argon2Hasher(),))
|
||||
bearer_scheme = HTTPBearer(auto_error=False)
|
||||
@@ -41,9 +42,7 @@ def hash_password(password: str) -> str:
|
||||
|
||||
|
||||
def verify_password(plain_password: str, password_hash: str) -> bool:
|
||||
if hasattr(pwd_context, "verify"):
|
||||
return pwd_context.verify(plain_password, password_hash)
|
||||
return pwd_context.check(plain_password, password_hash)
|
||||
return pwd_context.verify(plain_password, password_hash)
|
||||
|
||||
|
||||
def create_access_token(*, subject: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user