def test_access_token_expires_after_30_min() -> None:
    thirtyone_mins_from_now = generate_time_from_now(1860)
    uow = register_account_helper()
    access_token = get_access_token_helper(uow)

    with freeze_time(thirtyone_mins_from_now):
        with pytest.raises(ExpiredSignatureError):
            Authentication.verify_token(access_token)
Exemplo n.º 2
0
        def wrapper(*args: Any, **kwargs: Any) -> Any:
            if not authorization_header:
                raise AuthorizationError('No authorization header provided')

            access_token = authorization_header.split(' ')[1]

            if not access_token:
                raise AuthorizationError('No authorization token provided')

            try:
                Authentication.verify_token(access_token)
            except Exception as e:
                raise AuthorizationError(e) from e

            return func(*args, **kwargs)
Exemplo n.º 3
0
 def validate_verification_token(token: str) -> Dict[str, str]:
     try:
         verified_token = Authentication.verify_token(token)
         return verified_token
     except InvalidSignatureError as error:
         raise InvalidSignatureError(
             'Invalid verification token') from error