Skip to content

How to validate expiration? #1015

Answered by SvenRtbg
logneh4 asked this question in Q&A
Discussion options

You must be logged in to vote

canOnlyBeUsedAfter($now->modify('+10 minutes')) that invalidates the token until 10 minutes have passed. Then it becomes valid. But...

expiresAt($now->modify('+10 minutes')) it is invalid in 10 minutes, and I doubt you'd be able to find the microsecond (there is some leeway time config available to adjust non-synchronized clocks, but let's not consider that for now) where the code would consider the token valid.

"canOnlyBeUsedAfter" is to prevent tokens from being used before they become valid, so if a token is created in advance for some token rotation scheme, that would be a valid reason maybe to put a time of the future in.

In your case, put in exactly NOW, the token is valid the very …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by logneh4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants