INNER CODE UNIT · Python
__init__
tokusumi/fastapi-cloudauth · fastapi_cloudauth/auth0.py:93
def __init__(self, nonce: Optional[str] = None):
self._nonce = nonce
def __call__(self, claims: Dict[str, str], auto_error: bool = True) -> bool:
# TODO: check the aud more
# check the nonce
try:
nonce = claims["nonce"]
if nonce != self._nonce:
if auto_error:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED, detail=NOT_VERIFIED
)
return False
except KeyError:
pass
return True