Application fully migrated to modular approach
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# middleware/auth.py
|
||||
from fastapi import HTTPException, Depends
|
||||
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
||||
from fastapi import HTTPException
|
||||
from fastapi.security import HTTPAuthorizationCredentials
|
||||
from passlib.context import CryptContext
|
||||
from jose import jwt
|
||||
from datetime import datetime, timedelta
|
||||
@@ -15,9 +15,6 @@ logger = logging.getLogger(__name__)
|
||||
# Password context for bcrypt hashing
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
|
||||
# Security scheme
|
||||
security = HTTPBearer()
|
||||
|
||||
|
||||
class AuthManager:
|
||||
"""JWT-based authentication manager with bcrypt password hashing"""
|
||||
@@ -113,7 +110,7 @@ class AuthManager:
|
||||
logger.error(f"Token verification error: {e}")
|
||||
raise HTTPException(status_code=401, detail="Authentication failed")
|
||||
|
||||
def get_current_user(self, db: Session, credentials: HTTPAuthorizationCredentials = Depends(security)) -> User:
|
||||
def get_current_user(self, db: Session, credentials: HTTPAuthorizationCredentials) -> User:
|
||||
"""Get current authenticated user from database"""
|
||||
user_data = self.verify_token(credentials.credentials)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user