def _reject_future_iat(self, payload, now, leeway): try: iat = int(payload["iat"]) except ValueError: raise DecodeError("Issued At claim (iat) must be an integer.") if iat > (now + leeway): raise InvalidIssuedAtError("Issued At claim (iat) cannot be in" " the future.")
def decorated_function(*args, **kwargs): token = request.headers['authorization'] if not token: raise InvalidTokenError('Invalid token') parts = token.split(' ') if len(parts) > 2: raise InvalidTokenError('Invalid token') [scheme, token] = parts if scheme.strip() != 'Bearer': raise InvalidSignatureError('Invalid token signature') try: jwt.decode(token, variables.SECRET_KEY) return func(*args, **kwargs) except DecodeError: raise DecodeError('Token could not be decoded')
def decode_error(): raise DecodeError()