Git Product home page Git Product logo

Comments (6)

lestrrat avatar lestrrat commented on June 12, 2024

Better error reporting for jws.Verify is something that I'm absolutely 👍 for, but I'm not 100% as to exactly what you're going after.

For example,

If I got keys from jwk.Fetch and similar, I might be almost 100% sure that issue is because of invalid signature.
But would be nice to know that for sure.

What does this (jwk.Fetch) have to do with jws.Verify and verifyError?

Perhaps... are you dynamically loading keys in a KeyProvider? And this is failing and you want to differentiate against this line?

(If this is the case I can certainly accept a PR with your proposed change, as long as there are test cases included :)

from jwx.

arxeiss avatar arxeiss commented on June 12, 2024

I do

  1. claims, err := jwt.Parse(bearerToken, jwt.WithVerify(false))
  2. then based on value from claims.Issuer() I call keySet, err := jwk.Fetch() and do some caching
  3. and finally jws.Verify(bearerToken, jws.WithKeySet(keySet))

That's why I'm almost 100% sure, that if jws.Verify is failing, it is due to invalid signature, because token was parsed and keySet should be valid as it is returned by jwk.Fetch().

So I would like to differentiate basically any error from jws.Verify with this line https://github.com/lestrrat-go/jwx/blob/develop/v2/jws/jws.go#L451

from jwx.

lestrrat avatar lestrrat commented on June 12, 2024

Okay, so your proposed changes for IsVerifyError makes sense to me. I'm still on vacation, so if you're in a hurry, please consider filing a PR. Otherwise I will get on it sometime next week

from jwx.

lestrrat avatar lestrrat commented on June 12, 2024

@arxeiss I got other stuff that I also need to fix on this module, so I'll work on this now

from jwx.

lestrrat avatar lestrrat commented on June 12, 2024

@arxeiss Please check #1049. I opted to rename the function IsVerificationError. After implementing IsVerifyError, I compared it to jws.Verify and I thought it was unclear what IsVerifyError checks for from the naming -- technically, all errors returned from jws.Verify would be a "VerifyError", right? So while it's a bit more typing, I opted for the IsVerificationError name.

from jwx.

arxeiss avatar arxeiss commented on June 12, 2024

You were much faster than I'm. I had to focus to different task so I put this on hold. I checked the PR, seems good. Thank you

from jwx.

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.