Giter Club home page Giter Club logo

Comments (15)

cs-victor-nascimento avatar cs-victor-nascimento commented on September 28, 2024

I think this is only a question of supporting an optional parameter in all verify function variants. Something like:

def verify(other_parameters, options // []) do
  // check if options has skip_claims or skip_verifying
end

Though I really think that skipping verification is a somewhat dangerous option and I think we should ask if the new API supports the mentioned use case better.

@bryanjos @keichan34 what do you think?

from joken.

bryanjos avatar bryanjos commented on September 28, 2024

Good question. I think for skip_verifying, the none algorithm could be used. It's specifically used for unsecure JWSs if I'm reading the spec correctly. For skip_claims, we could add an option as stated or maybe another function to remove validations from the Token struct?

from joken.

cs-victor-nascimento avatar cs-victor-nascimento commented on September 28, 2024

I'd say both 👍

from joken.

bryanjos avatar bryanjos commented on September 28, 2024

Actually I may have to rethink what I said about the none algorithm for this. You would still need the algorithm to decode it. For skip_claims, which one do you think works better, adding it to the options or a remove_validations function?

from joken.

cs-victor-nascimento avatar cs-victor-nascimento commented on September 28, 2024

I think we should have both an option parameter and a remove_validation function. They would work a bit different. The skip_claims in the option list would skip for that single verification and the remove_validation would remove it from then on.

from joken.

cs-victor-nascimento avatar cs-victor-nascimento commented on September 28, 2024

@keichan34 do you still have the use case of skipping verification? Does the new API help with your use case? If that is not a problem I'll propose to close this issue.

Thanks!

from joken.

keichan34 avatar keichan34 commented on September 28, 2024

I do have this use case, yes. The "none" algorithm would work, but I think for now it may be out of the scope of this project? I can parse the token for its claims manually, so I might end up just doing that. (I'm validating the token based on what is in the "iss" claim -- this is probably an edge case?)

The other changes look great!

from joken.

cs-victor-nascimento avatar cs-victor-nascimento commented on September 28, 2024

I think that is somewhat an edge case yes. The none algorithm would probably not help you much here because you would run verify 2 times (one with a token configuration with a none signer and one with your real signer) and that is unnecessary. I guess your best bet is to take the second part of the token (the one between dots) and decode it on your own to take the iss claim.

Another approach (and probably safer) is to use the token header. It might contain some specific data like kid (key id) which could help in cases where you have different keys for verifying. Right now we have no means to pre-process the header of a token (where you could look for the kid). That seems like a candidate for a future version. @bryanjos we should think about it!

Other than that I've been thinking about and talking with @bryanjos about adding some context to validating functions but that happens after after signature verification and so wouldn't help you either.

from joken.

keichan34 avatar keichan34 commented on September 28, 2024

I'll go ahead with decoding the token on my own, then. Thanks for your help! Looking forward to the release. 😃

from joken.

bryanjos avatar bryanjos commented on September 28, 2024

Awesome! I guess this is resolved for now so I'll close this issue.

from joken.

bryanjos avatar bryanjos commented on September 28, 2024

Reopening as it seems the use case for getting claims before verification is a common one and one we should implement. Erlang-Jose is going to implement something similar and we can build off of that.

from joken.

cs-victor-nascimento avatar cs-victor-nascimento commented on September 28, 2024

@bryanjos I have a question about this use case: should we implement it inside the signing or verifying steps or as a standalone function outside of these steps?

I mean, the first case can be used to notify or log before signing and verifying. The second case can be used to change which keys to use. I think this is the one asked the first time, right?

If that is so, we don't need to wait for erlang-jose. We can simply export a function that will use return the claim map.

What do you think?

from joken.

bryanjos avatar bryanjos commented on September 28, 2024

@cs-victor-nascimento it looks like there is a JOSE.JWS.peek/1 function now in erlang-jose which is the one @potatosalad said he was going to implement. We could make it it's own function I guess if it makes sense to. We could name it "peek" as well. I have some time now to look into it

from joken.

cs-victor-nascimento avatar cs-victor-nascimento commented on September 28, 2024

@bryanjos peek is already merged! As mentioned, that fixes this use case and we are good to close this one, right?

from joken.

bryanjos avatar bryanjos commented on September 28, 2024

Yes, peek has been merged and should resolve this issue. Closing now

from joken.

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.