Repository: jpadilla/pyjwt

Issue:
PyJWT 2.6.0 IAT Decode Error - TypeError: '>' not supported between instances of 'str' and 'int'
# Summary
Just upgraded to version `2.6.0` and now whenever I try to do a decode of a JWT I get the following error:
```python
def _validate_iat(self, payload, now, leeway):
        iat = payload["iat"]
        try:
            int(iat)
        except ValueError:
            raise InvalidIssuedAtError("Issued At claim (iat) must be an integer.")
>       if iat > (now + leeway):
E       TypeError: '>' not supported between instances of 'str' and 'int'
```

It appears that the `iat` value is "trying" to be converted (and if not, raises an exception) but doesn't actually evaluate the `iat` value as an int.

My payload comes across like:
```python
payload["iat"] = '1638202770'
```
So trying to perform `>` operations on that will result in a string. This does not happen in version `2.5.0` so I believe this is a regression.

## Expected Result

A valid decode of my JWT value:
```python
import jwt

decoded = jwt.decode(data, pub_key, algorithms=["RS256"], audience=["x.com"])

print(decoded)
```

## Actual Result

```python
def _validate_iat(self, payload, now, leeway):
        iat = payload["iat"]
        try:
            int(iat)
        except ValueError:
            raise InvalidIssuedAtError("Issued At claim (iat) must be an integer.")
>       if iat > (now + leeway):
E       TypeError: '>' not supported between instances of 'str' and 'int'
```

## Reproduction Steps

```python
import jwt

data = <jwt_content>
pub_key = <path_to_pub_key>

decoded = jwt.decode(data, pub_key, algorithms=["RS256"], audience=["x.com"])
```

## System Information

    $ python -m jwt.help

```
{
  "cryptography": {
    "version": "38.0.1"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.9.13"
  },
  "platform": {
    "release": "20.6.0",
    "system": "Darwin"
  },
  "pyjwt": {
    "version": "2.6.0"
  }
}

```

This command is only available on PyJWT v1.6.3 and greater. Otherwise,
please provide some basic information about your system.


Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 3c69338..12117ec 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -16,6 +16,7 @@ Fixed
 ~~~~~
 
 - Add classifier for Python 3.11 by @eseifert in `#818 <https://github.com/jpadilla/pyjwt/pull/818>`_
+- Fix ``_validate_iat`` validation by @Viicos in `#847 <https://github.com/jpadilla/pyjwt/pull/847>`_
 
 Added
 ~~~~~
diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py
index fd8a8bf..5664949 100644
--- a/jwt/api_jwt.py
+++ b/jwt/api_jwt.py
@@ -265,9 +265,8 @@ class PyJWT:
         now: float,
         leeway: float,
     ) -> None:
-        iat = payload["iat"]
         try:
-            int(iat)
+            iat = int(payload["iat"])
         except ValueError:
             raise InvalidIssuedAtError("Issued At claim (iat) must be an integer.")
         if iat > (now + leeway):


Test patch:
diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py
index d74973d..24ed240 100644
--- a/tests/test_api_jwt.py
+++ b/tests/test_api_jwt.py
@@ -227,6 +227,13 @@ class TestJWT:
         with pytest.raises(ImmatureSignatureError):
             jwt.decode(jwt_message, secret, algorithms=["HS256"])
 
+    def test_decode_works_if_iat_is_str_of_a_number(self, jwt, payload):
+        payload["iat"] = "1638202770"
+        secret = "secret"
+        jwt_message = jwt.encode(payload, secret)
+        data = jwt.decode(jwt_message, secret, algorithms=["HS256"])
+        assert data["iat"] == "1638202770"
+
     def test_decode_raises_exception_if_nbf_is_not_int(self, jwt):
         # >>> jwt.encode({'nbf': 'not-an-int'}, 'secret')
         example_jwt = (