Allow a leeway to be given for the iat claim verification - #747
Open
denis1011101 wants to merge 1 commit into
Open
Allow a leeway to be given for the iat claim verification#747denis1011101 wants to merge 1 commit into
denis1011101 wants to merge 1 commit into
Conversation
The iat claim is verified with an exact comparison against the local
clock, so a token is rejected whenever the clock of the issuer is even
marginally ahead of the clock of the verifier. There was no way to
tolerate that drift: the global leeway option does not apply to this
claim and iat_leeway was removed in 2.2.0.
Accept a leeway for the claim, defaulting to 0 so that the current
behaviour is unchanged, and keep the comparison exact:
JWT.decode(token, secret, true, verify_iat: { leeway: 30 })
JWT::Claims.verify_payload!(payload, iat: { leeway: 30 })
Refs jwt#353
denis1011101
force-pushed
the
add-iat-leeway
branch
from
August 29, 2026 10:32
c219ef1 to
547bc8b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
leewayto theiatverification. Refs #353.Right now
iatis compared exactly against the local clock, so a token getsrejected as soon as the issuer's clock is slightly ahead of the verifier's.
There's no way to allow for that: the global
leewaydoesn't apply to thisclaim, and
iat_leewaywas dropped in 2.2.0.In #353 (comment) anakinj
suggested keeping the comparison exact and letting the caller say how much drift
is acceptable, so that's what this does:
It defaults to
0, so nothing changes for existing code. The value is read fromthe claim's own options, as in that comment, which keeps the old
iat_leewayname out of the API.
Refs rather than Closes, since the default behaviour stays as it was.
Checklist
Before the PR can be merged be sure the following are checked: