Skip to content

Commit

Permalink
feat: Improve handling of clock skew (#858)
Browse files Browse the repository at this point in the history
* Allow up to 60 seconds of skew

* Add actionable/helpful error message text.

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: arithmetic1728 <58957152+arithmetic1728@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 7, 2021
1 parent 11ebaeb commit 45c4491
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion google/auth/_helpers.py
Expand Up @@ -20,7 +20,7 @@
import urllib


CLOCK_SKEW_SECS = 10 # 10 seconds
CLOCK_SKEW_SECS = 60 # 60 seconds
CLOCK_SKEW = datetime.timedelta(seconds=CLOCK_SKEW_SECS)


Expand Down
6 changes: 5 additions & 1 deletion google/auth/jwt.py
Expand Up @@ -190,7 +190,11 @@ def _verify_iat_and_exp(payload):
# for clock skew.
earliest = iat - _helpers.CLOCK_SKEW_SECS
if now < earliest:
raise ValueError("Token used too early, {} < {}".format(now, iat))
raise ValueError(
"Token used too early, {} < {}. Check that your computer's clock is set correctly.".format(
now, iat
)
)

# Make sure the token wasn't issued in the past.
exp = payload["exp"]
Expand Down

0 comments on commit 45c4491

Please sign in to comment.