Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate iat as int #252

Merged
merged 3 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pycognito/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def verify_token(self, token, id_name, token_use):
issuer=self.user_pool_url,
options={
"require": required_claims,
"verify_iat": False,
},
)
except jwt.PyJWTError as err:
Expand All @@ -274,6 +275,14 @@ def verify_token(self, token, id_name, token_use):
f"Your {id_name!r} token use ({token_use!r}) could not be verified."
)

if (iat := verified.get("iat")) is not None:
try:
int(iat)
except ValueError as execption:
raise TokenVerificationException(
f"Your {id_name!r} token's iat claim is not a valid integer."
) from execption

# Compute and verify at_hash (formerly done by python-jose)
if "at_hash" in verified:
alg_obj = jwt.get_algorithm_by_name(header["alg"])
Expand Down