Code Monkey home page Code Monkey logo

Comments (8)

progrium avatar progrium commented on August 27, 2024

No, this looks right. I was just too used to the hexdigest representation of HMAC and the spec was not terribly clear about this. I'm updating my other libs (PyJWT and php-jwt) as well. Can you share a JWT produced with your lib for me to use in my tests? Preferably:

payload json: {"hello": "world"}
key: "secret"
alg: HS256

from ruby-jwt.

progrium avatar progrium commented on August 27, 2024

Fixed and released. For now I'm using one generated by the fixed version of the library. Hopefully you'd have generated the same:

eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJoZWxsbyI6ICJ3b3JsZCJ9.tvagLDLoaiJKxOKqpBXSEGy7SYSifZhjntgm9ctpyj8

from ruby-jwt.

seregine avatar seregine commented on August 27, 2024

I can come close. The spec requires the "issuer" claim, so here's what I get:

Encoded token:
eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3N1ZXIiLCJoZWxsbyI6IndvcmxkIn0.DpAMLPYNOvukLtXpEWncK0dOV6vKWvp1KAi8NVcCFcg
Token header:
{"alg":"HS256"}
Token payload:
{"iss":"issuer","hello":"world"}

from ruby-jwt.

seregine avatar seregine commented on August 27, 2024

Also, thank you for fixing it so fast!

from ruby-jwt.

progrium avatar progrium commented on August 27, 2024

According to the spec, the issuer is optional!

http://self-issued.info/docs/draft-jones-json-web-token-01.html#ReservedClaimName

from ruby-jwt.

seregine avatar seregine commented on August 27, 2024

Right, thanks for catching that. I'll fix that in my code. Now this is the closest I'll get (whitespace is the difference):

Yours:
{"alg": "HS256", "typ": "JWT"}.{"hello": "world"}

Mine:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJoZWxsbyI6IndvcmxkIn0.lnneNaoem98xYFES3mi2CJJjnMONuWAu-FTWB3XJN14
{"alg":"HS256","typ":"JWT"}.{"hello":"world"}

BTW the Java library doesn't insert "typ":"JWT" because it's also optional, I just added it here to come closer to your example.

from ruby-jwt.

progrium avatar progrium commented on August 27, 2024

Ah, but it works! So good.

Yes, I'm surprised I decided to include typ by default.

Btw, where's your Java implementation?

from ruby-jwt.

seregine avatar seregine commented on August 27, 2024

It's this one. It's not "mine" so much as I'm updating it:
http://code.google.com/p/jsontoken/

from ruby-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.