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

Verify exp claim/field even if it's not present #363

Closed
pjmartorell opened this issue Jul 21, 2020 · 2 comments
Closed

Verify exp claim/field even if it's not present #363

pjmartorell opened this issue Jul 21, 2020 · 2 comments

Comments

@pjmartorell
Copy link

Is there a way to enforce the verification of exp or iat claim/field? I checked the implementation and claims/fields are only verified if they are present. In my opinion there should be a way to force the verification and prevent mistakenly not adding these claims. What do you think?

@danleyden
Copy link
Contributor

The main focus of this gem is about verifying the validity and correctness of the token itself. The RFC that it follows requires that the token be deemed invalid if those claims are provided and not correct.

What I believe you're looking for is policy enforcement beyond the RFC - i.e. not just "is this token valid?" but "does this token match my application's requirements?". This gem's focus is the first question, because the second is a much, much harder problem to solve generically because of the multitude of ways in which JWTs are used... For example, in some use cases, exp may be required only if the iss claim is provided with a specific value.

I would suggest creating a wrapper that first uses the gem's verify to assert the token's correctness, then to assert any policy you may have such as must include exp and. iat claims

@pjmartorell
Copy link
Author

I understand your point but, I'll try to find a nice way to validate the presence of these claims 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants