News for hackers. Stuff that matters.
Re:Things to Use Instead of JSON Web Tokens by theprotocol on Monday May 08, 2017 @05:40AM (#14290291)
You could even hit 2 birds with 1 stone by going with headerless JWTs (just strip the first segment).
Re:Things to Use Instead of JSON Web Tokens by davis_m on Monday May 08, 2017 @10:50AM (#14291959)
You can run into issues with headerless JWTs when you can't (or don't) guarantee the order of the header. Since the header is included in the signature of JWS objects, you must reattach a header that is exactly the same, and not just equivalent.

For example, both of these decoded headers are equivalent:

{ "alg": "HS256", "typ": "JWT" }

{ "typ": "JWT", "alg": "HS256" }

Obviously, these encode to two different values. If you reattach the wrong one, signature verification will fail.

Disclaimer: I maintain a Python JOSE library and have had to answer questions related to this on more than one occasion.

Re:Things to Use Instead of JSON Web Tokens by Freak_NL on Monday May 08, 2017 @05:45AM (#14290310)
Keeping the JWT format as-is is useful if you have signed (but not encrypted) tokens though; in a web browser you can use standard libraries to inspect the token and alter the UI based on a user's permissions (the final check is always the API's responsibility of course, but if there is no need to show the 'admin' link the client can do that).
Re:Things to Use Instead of JSON Web Tokens by theprotocol on Monday May 08, 2017 @05:49AM (#14290330)
If it isn't encrypted, the only thing the client needs to know is that it's base64 encoded in order to inspect it. You'd need the secret to verify the signing and you probably shouldn't have that on the client-side!

So I still think the header is superfluous even for this use case.

edit: in fact, the client needs to know that it's base64 encoded to even read the header in the first place.

Re:Things to Use Instead of JSON Web Tokens by vertex-four on Monday May 08, 2017 @06:06AM (#14290398)
Symmetric signing is not, by far, the only use case for JWTs. Asymmetric signing, and encryption, are also well-specified and supported.
Re:Things to Use Instead of JSON Web Tokens by theprotocol on Monday May 08, 2017 @06:13AM (#14290434)
Good point! It slipped my mind.
Re:Things to Use Instead of JSON Web Tokens by lclarkmichalek on Monday May 08, 2017 @06:08AM (#14290413)
There's some value in the header. Google use it to store the keyid, which is pretty useful.