new refresh dep add refresh endpoint
This commit is contained in:
@@ -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},
|
||||
)
|
||||
|
||||
@@ -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": ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user