fix: use explicit None checks for JWT exp validation (#3724)

This commit is contained in:
Jeremiah Lowin 2026-03-31 12:02:44 -04:00 committed by GitHub
commit 61f3feec6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View file

@ -246,7 +246,7 @@ class JWTIssuer:
# Validate expiration
exp = payload.get("exp")
if exp and exp < time.time():
if exp is not None and exp < time.time():
logger.debug("Token expired")
raise JoseError("Token has expired")

View file

@ -286,7 +286,7 @@ class IntrospectionTokenVerifier(TokenVerifier):
token=token,
client_id=str(client_id),
scopes=scopes,
expires_at=int(exp) if exp else None,
expires_at=int(exp) if exp is not None else None,
claims=introspection_data, # Store full response for extensibility
)
self._cache.set(token, result)

View file

@ -421,7 +421,7 @@ class JWTVerifier(TokenVerifier):
# Validate expiration
exp = claims.get("exp")
if exp and exp < time.time():
if exp is not None and exp < time.time():
self.logger.debug(
"Token validation failed: expired token for client %s", client_id
)
@ -501,7 +501,7 @@ class JWTVerifier(TokenVerifier):
token=token,
client_id=str(client_id),
scopes=scopes,
expires_at=int(exp) if exp else None,
expires_at=int(exp) if exp is not None else None,
claims=claims,
)