Skip to content

Matching jwt token against a regex #38

Closed

Description

@sohailalam2

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

Activity

  1. omsmith commented on Jan 14, 2016

    @omsmith
    Contributor

    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 (=).

  2. sohailalam2 commented on Jan 14, 2016

    @sohailalam2
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions