fix auth lifetime

This commit is contained in:
2024-04-07 21:31:15 +00:00
parent f8f5bf80c1
commit d55e8d1df3
13 changed files with 212 additions and 42 deletions

View File

@@ -17,7 +17,7 @@ class JoseJwtTokenProcessor(JwtTokenProcessor):
def generate_token(self, user_id: UserId) -> str:
issued_at = self.date_time_provider.get_current_time()
expiration_time = issued_at + timedelta(hours=self.jwt_options.expires_in)
expiration_time = issued_at + timedelta(minutes=self.jwt_options.expires_in)
claims = {
"iat": issued_at,
@@ -30,8 +30,10 @@ class JoseJwtTokenProcessor(JwtTokenProcessor):
def validate_token(self, token: str) -> UserId | None:
try:
payload = decode(token, self.jwt_options.secret, [self.jwt_options.algorithm])
return UserId(UUID(payload["sub"]))
except (JWTError, ValueError, KeyError):
return None
def refresh_token(self, token: str) -> str:
return ""