new refresh dep add refresh endpoint

This commit is contained in:
IluaAir
2025-09-21 14:59:26 +03:00
parent c3bfb9cb6a
commit 42b8c3a2c9
12 changed files with 125 additions and 66 deletions

View File

@@ -34,19 +34,17 @@ class AuthManager:
algorithm=settings.access_token.algorithm,
)
return encoded_jwt
@classmethod
def create_refresh_token(cls) -> str:
# random_bytes = os.urandom(32)
# data = settings.refresh_token.secret_key.encode() + random_bytes
# token_hash = bcrypt.hashpw(data, bcrypt.gensalt(rounds=12)).decode()
token_hash = secrets.token_urlsafe(32)
return token_hash
@classmethod
def decode_access_token(cls, token: str) -> dict:
def decode_access_token(cls, token: str, verify_exp: bool = True) -> dict:
return jwt.decode(
token,
settings.access_token.secret_key,
algorithms=[settings.access_token.algorithm],
options={"verify_exp": verify_exp},
)

View File

@@ -14,9 +14,9 @@ class HasId(Protocol):
class IUOWDB(Protocol):
session: AsyncSession
user: 'UsersRepo'
task: 'TasksRepo'
auth: 'AuthRepo'
user: "UsersRepo"
task: "TasksRepo"
auth: "AuthRepo"
async def __aenter__(self) -> "IUOWDB": ...