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

Matching jwt token against a regex #38

Closed
sohailalam2 opened this issue Jan 14, 2016 · 3 comments
Closed

Matching jwt token against a regex #38

sohailalam2 opened this issue Jan 14, 2016 · 3 comments

Comments

@sohailalam2
Copy link

Hey Guys,

We are facing some issues with the jsonwebtoken library when we create our own token following the JWT standards (using C language). Unfortunately the official C library doesnt compile well in our Windows environment.

After debugging for days we came to the conclusion that the regex used in the jws library verify-stream.js file does not allow for equals sign (=), hence the regex validation fails.

Currently the regex looks like as follow -

const JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;

Suggested change is to include the (=) sign as well -

const JWS_REGEX = "^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$";

Thanks

@omsmith
Copy link
Contributor

omsmith commented Jan 14, 2016

Dupe of #22

Sorry, but your C implementation is not following the spec.

The JOSE set of standards uses "URL safe Base64".

Replace + with -, / with _, and remove all padding (=).

@sohailalam2
Copy link
Author

@omsmith Thank you for the quick response. We will make the required chanes as suggested.

@vanillajonathan
Copy link

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

3 participants