Comments (8)
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.
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.
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.
Also, thank you for fixing it so fast!
from ruby-jwt.
According to the spec, the issuer is optional!
http://self-issued.info/docs/draft-jones-json-web-token-01.html#ReservedClaimName
from ruby-jwt.
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.
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.
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)
- Drop the custom Base64 encode and decode to favour the built-in methods
- Are there breaking changes between 1.x and 2.x? HOT 2
- Possibility to override the alg header when encoding tokens HOT 2
- Bug: undefined method `casecmp' for nil:NilClass when invalid alg
- Support x5t in place of kid
- verification of at_hash == access_token HOT 4
- OpenSSL 3 - Unable to create OpenSSL::PKey instances from pem/der/asn sequences HOT 1
- Alg optional member Readme HOT 5
- Yeah steady stay
- 50
- 100 HOT 2
- How should I verify JWS with x5c certs with no CRL? HOT 6
- جدة
- JWT not being signed HOT 2
- Deprecation warning for invalid base64 should only be issued if fixed base64 is valid HOT 2
- شارع الربعين HOT 5
- H
- eyJhbGciOiJub25lIn0.eyJhZGRyZXNzIjp7InppcGNvZGUiOm51bGwsInN0cmVldG5vIjpudWxsLCJjaXR5IjoiQUwtQUZMQUciLCJzdHJlZXQiOm51bGx9LCJ0b2tlblVVSUQiOiI3Zjk1Yzc0ZDA3Y2M0OGI1OWNlNzhlYzBlZTU.
- T
- ExpiredSignature should perhaps not be a subclass of DecodeError HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-jwt.