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

Updated isJWT so it's conforming to specs #906

Merged
merged 1 commit into from
Oct 11, 2018

Conversation

ItalyPaleAle
Copy link
Contributor

@ItalyPaleAle ItalyPaleAle commented Oct 10, 2018

Updated the regular expression for isJWT so it's conforming to the specs.

#609 contained a regular expression where the signature part was required. However, RFC 7519 states:

To support use cases in which the JWT content is secured by a means
other than a signature and/or encryption contained within the JWT
(such as a signature on a data structure containing the JWT), JWTs
MAY also be created without a signature or encryption. An Unsecured
JWT is a JWS using the "alg" Header Parameter value "none" and with
the empty string for its JWS Signature value, as defined in the JWA
specification [JWA]; it is an Unsecured JWS with the JWT Claims Set
as its JWS Payload.

Note that the code in the PR doesn't check if "alg" is actually "none" when the signature is missing, as it doesn't decode the JWT... I'm happy to implement that if you think I should, however.

I have also added some stricter checks to ensure that the base64 tokens are valid.

@chriso
Copy link
Collaborator

chriso commented Oct 11, 2018

Thanks!

@chriso chriso merged commit 439c51f into validatorjs:master Oct 11, 2018
chriso added a commit that referenced this pull request Oct 11, 2018
@ItalyPaleAle ItalyPaleAle deleted the patch/jwt branch October 11, 2018 16:43
@ezkemboi ezkemboi mentioned this pull request Aug 10, 2019
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

Successfully merging this pull request may close these issues.

2 participants