Code Monkey home page Code Monkey logo

Comments (5)

mark-adams avatar mark-adams commented on August 16, 2024 1

So, the big question here would be... how would you handle conflict? If a consumer passed in a payload to encode() that already had "aud" set but they also passed in a value for audience=

I think the best thing in that situation would be to throw an exception. It seems like any other option would result in a confusing API.

from pyjwt.

jpadilla avatar jpadilla commented on August 16, 2024

@wbolster hmm not sure I understand your proposal. Mind showing an example or use case?

from pyjwt.

wbolster avatar wbolster commented on August 16, 2024

Code to encode a token, e.g.

payload = {}
token = pyjwt.encode(d, key)

takes no audience= or issuer= args, while this does:

payload = pyjwt.decode(token, key, audience='foo', issuer='bar')

This means that application authors need to know internal details of the JWT spec if they want to generate tokens with audience or issuer claims embedded in them, since the only way to do so (currently) is to put aud and iss keys (with conforming values) into the payload dict. If applications put invalid data structures into those values, the token will be generated without error, but it will be non-compliant.

I argue that this is a discrepancy between encode/decode, since for decoding pyjwt takes care of the correct interpretation of the JWT spec to validate the audience and issuer claims, while for encoding application authors are on their own, since pyjwt doesn't help at all here.

Please let me know whether I've explained myself better this time. :)

from pyjwt.

jpadilla avatar jpadilla commented on August 16, 2024

@wbolster yeah definitely makes sense now

from pyjwt.

wbolster avatar wbolster commented on August 16, 2024

ok feel free to assign this issue to me. no guarantees about time frame but I'll see what I can do :-)

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.