diff --git a/src/fastmcp/server/auth/jwt_issuer.py b/src/fastmcp/server/auth/jwt_issuer.py index 4e17eac60..78635b90c 100644 --- a/src/fastmcp/server/auth/jwt_issuer.py +++ b/src/fastmcp/server/auth/jwt_issuer.py @@ -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") diff --git a/src/fastmcp/server/auth/providers/introspection.py b/src/fastmcp/server/auth/providers/introspection.py index 65d9d86ce..f24b54833 100644 --- a/src/fastmcp/server/auth/providers/introspection.py +++ b/src/fastmcp/server/auth/providers/introspection.py @@ -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) diff --git a/src/fastmcp/server/auth/providers/jwt.py b/src/fastmcp/server/auth/providers/jwt.py index a97c1bd60..17194329f 100644 --- a/src/fastmcp/server/auth/providers/jwt.py +++ b/src/fastmcp/server/auth/providers/jwt.py @@ -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, )