You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would suggest an update where you can cache jwk set
classJsonWebToken:
"""Perform JSON Web Token (JWT) validation using PyJWT"""jwt_access_token: strauth0_issuer_url: str=f"https://{settings.auth0_domain}/"auth0_audience: str=settings.auth0_audiencealgorithm: str="RS256"jwks_uri: str=f"{auth0_issuer_url}.well-known/jwks.json"jwks_client=jwt.PyJWKClient( # having the client created once will keep the cache as long as the app runningjwks_uri,
ssl_context=ctx,
cache_jwk_set=True,
cache_keys=True,
)
defvalidate(self):
try:
jwt_signing_key=self.jwks_client.get_signing_key_from_jwt(
token=self.jwt_access_token
).keypayload=jwt.decode(
self.jwt_access_token,
jwt_signing_key,
algorithms=self.algorithm,
audience=self.auth0_audience,
issuer=self.auth0_issuer_url,
)
exceptjwt.exceptions.PyJWKClientErrorase:
print(e)
raiseUnableCredentialsExceptionexceptjwt.exceptions.InvalidTokenError:
raiseBadCredentialsExceptionreturnpayload
Activity