diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fb936fd0..61fd5a94 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,7 @@ Fixed Added ~~~~~ +- Adding validation for `issued_at` when `iat > (now + leeway)` as `ImmatureSignatureError` by @sriharan16 in https://github.com/jpadilla/pyjwt/pull/794 `v2.5.0 `__ ----------------------------------------------------------------------- diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py index bebe7d28..d74973df 100644 --- a/tests/test_api_jwt.py +++ b/tests/test_api_jwt.py @@ -219,6 +219,14 @@ def test_decode_raises_exception_if_iat_is_not_int(self, jwt): with pytest.raises(InvalidIssuedAtError): jwt.decode(example_jwt, "secret", algorithms=["HS256"]) + def test_decode_raises_exception_if_iat_is_greater_than_now(self, jwt, payload): + payload["iat"] = utc_timestamp() + 10 + secret = "secret" + jwt_message = jwt.encode(payload, secret) + + with pytest.raises(ImmatureSignatureError): + jwt.decode(jwt_message, secret, algorithms=["HS256"]) + def test_decode_raises_exception_if_nbf_is_not_int(self, jwt): # >>> jwt.encode({'nbf': 'not-an-int'}, 'secret') example_jwt = (