Relax restrictions on "jti" claim verification #113
Merged
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.
The RFC has the following to say about the "jti" claim:
The current implementation expects that the
jti
is built as:anything else is not considered a valid
jti
. There are several issues with the current implementation:secret + ":" + iat
is not exactly collision safe :) using random UUIDs is safer I'd say.This pull request simply relaxes the verification of the "jti" claim to be present. This is in line with other implementations like the one for Java or Python. (FYI, there are other implementations that perform additional checks, the one seen most common is to verify against a fixed value supplied in the
verify
call).It is my opinion that the library should just provide basic validation and make no additional assumption about the
jti
. Any additional verification / validation (e.g. replay checks, value checks) must be checked by the application and should be out of the scope for the library.PS: Yes, one could argue about having the option to supply an expected value for the "jti" claim, but this is IMO not really reasonable, because it (should) change for every JWT generated. So it's not something quasi-static like e.g. the issuer or audience.