Code Monkey home page Code Monkey logo

Comments (8)

wbolster avatar wbolster commented on August 16, 2024

...but those were never part of the public (documented) API, right?

I think if this functionality makes sense to expose (can you elaborate on the use case?) it will need some big fat "this is possibly unsafe" warnings and preferably also corresponding names, e.g. unsafe_load() and so on.

from pyjwt.

jpadilla avatar jpadilla commented on August 16, 2024

What @wbolster said.

from pyjwt.

tilgovi avatar tilgovi commented on August 16, 2024

Ah, I see that they weren't, in fact, in __all__, even in 0.4.1 where they were in the package main module.

The use case is, I think, not uncommon. I serve multiple issuers. I need to inspect the issuer before I know which secret to use. On the other hand, this is just premature optimization where I'm trying to avoid the base64 decode when it comes time to verify.

Up to you all, then. I'm happy to submit a patch, with whatever scary names you think are appropriate, if it seems reasonable to make these public. Otherwise, no big deal.

from pyjwt.

jpadilla avatar jpadilla commented on August 16, 2024

I'm still not sure this should be public API, unless we have others interested in it being it. For now, you'll still be able to import it directly from jwt.api.

from pyjwt.

tilgovi avatar tilgovi commented on August 16, 2024

Yep. Closing. If more people come across this they can speak up if they want it.

from pyjwt.

garyp avatar garyp commented on August 16, 2024

I have the same need as @tilgovi: verifying jwt's received from multiple issuers, with a different key per issuer. Thus I need to get the issuer out of the jwt in order to pass in the appropriate key for verification.

from pyjwt.

tilgovi avatar tilgovi commented on August 16, 2024

I think it makes sense to expose an API for this.

As for safety for the user and bw-compat what if there were a keyword argument for decode that returned the parts tuple and we just exposed verify but not load?

(payload, signing_input, header, signature) = decode(..., verify=False, parts=True)
if verify(payload, signing_input, header, signature) ...

That way, verify=False would have to be the explicit opt-in rather than trying to come up with a "safe" name for load?

from pyjwt.

tilgovi avatar tilgovi commented on August 16, 2024

OTOH, I don't like when functions have multiple return types.

from pyjwt.

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.