Giter Club home page Giter Club logo

Comments (9)

lcobucci avatar lcobucci commented on May 18, 2024

Thanks @absolux for your contribution.

The ValidationData is not a validator, but is "bag" to define your expectations about the token. In that way you're required to inform what do you want to be validated.

To make your code work you have to do this:

$builder = new Builder();
$token = $builder->setSubject(1)->getToken();
$validator = new ValidationData();
$validator->setSubject(2); // if you don't set this the "sub" claim will be just ignored in the validation.
$this->assertFalse($token->validate($validator));

My ideia was to say: hey token are you valid against this data?

from jwt.

lcobucci avatar lcobucci commented on May 18, 2024

But you remind me to create a new issue about the token validation process 😄

from jwt.

lcobucci avatar lcobucci commented on May 18, 2024

I think this should be explained better in the documentation section

from jwt.

absolux avatar absolux commented on May 18, 2024

yes indeed, but ValidationData object has by default 3 claims [iat, exp, nbf] not validated by the token, because they are absent, and my test will always fail in case the token is not signed.

So, for that reason, ValidationData should know about required claims, and returns false before checking claims values

from jwt.

lcobucci avatar lcobucci commented on May 18, 2024

Thanks again @absolux.
After taking more time to analyse your report I've found the reason why you're getting the wrong return from Token::validate() method.

It's not related with what you're saying, but actually with types and === comparison used by Claims\EqualsTo.

Builder converts the subject claim to a string, but ValidationData doesn't. So when you're using int as subject things get messy 😄. I'll be fixing it right now and adding more tests.

from jwt.

lcobucci avatar lcobucci commented on May 18, 2024

BTW token validation and signature verification are different things. That's why this isn't related with having unsigned tokens.

from jwt.

lcobucci avatar lcobucci commented on May 18, 2024

@absolux I just released the version 3.0.3 with this fix, can you check if everything is fine now?

from jwt.

absolux avatar absolux commented on May 18, 2024

Thanks a lot for the update, and the documentation is more clear now. 👍

from jwt.

lcobucci avatar lcobucci commented on May 18, 2024

Awesome @absolux! Some 🍻 to you for reporting this!

from jwt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.