jpadilla / pyjwt

JSON Web Token implementation in Python
https://pyjwt.readthedocs.io
MIT License
5.05k stars 676 forks source link

Fix `_validate_iat` validation #847

Closed Viicos closed 1 year ago

Viicos commented 1 year ago

Fixes #817.

ridwanrahman commented 11 months ago

Recently, I have been getting an ImmatureSignatureError. I have not been able to figure out how its been caused or when its being caused. It shows up randomly and then works at other time. Here's the log

File "/usr/local/lib/python3.8/dist-packages/jwt/api_jwt.py", line 210, in decode decoded = self.decode_complete( File "/usr/local/lib/python3.8/dist-packages/jwt/api_jwt.py", line 162, in decode_complete self._validate_claims( File "/usr/local/lib/python3.8/dist-packages/jwt/api_jwt.py", line 242, in _validate_claims self._validate_iat(payload, now, leeway) File "/usr/local/lib/python3.8/dist-packages/jwt/api_jwt.py", line 278, in _validate_iat raise ImmatureSignatureError("The token is not yet valid (iat)") jwt.exceptions.ImmatureSignatureError: The token is not yet valid (iat) Showing last 1 frames of 26... Frame _validate_iat in /usr/local/lib/python3.8/dist-packages/jwt/api_jwt.py at line 278 self = <jwt.api_jwt.PyJWT object at 0x7f2da46e5f10> payload = Dict object with keys: email, email_verified, nickname, name, picture, updated_at, iss, aud, iat, exp, sub, sid now = 1693446660.79521 leeway = 0 iat = 1693446661

I wonder if this is being caused due to iat = int(payload["iat"])

Viicos commented 11 months ago

I don't think this is related to this PR. Your client and/or server clock are probably not synced correctly. Using the leeway parameter can maybe help