3 ms·
> These tokens are usually signed to protect against manipulation (not encrypted) so the data in the claims can be easily decoded and read Is this really true?
by Kiro 10y ago
> These tokens are usually signed to protect against manipulation (not encrypted) so the data in the claims can be easily decoded and read
Is this really true? I mean, if you can decode the token you must have access to the secret anyway?
From https://github.com/auth0/node-jsonwebtoken https://github.com/auth0/node-jsonwebtoken
var token = jwt.sign({ foo: 'bar' }, 'shhhhh');
var decoded = jwt.verify(token, 'shhhhh');
console.log(decoded.foo) // bar
- nbarbettini 10y agoEncoding != encryption. This article isn't discussing JWE (JSON Web Encryption), but rather JWS (JSON Web Signature). These tokens are base64-encoded and signed. They can be decoded easily, but not forged or altered without knowledge of the secret key.
- ejcx 10y agoIf you have a secret in the JWT you definitely want to encrypt it (JWE instead of JWS). But yes, it's true. A signature will protect against manipulation though, like the article points out, which is enough for a lot of applications.
- mwpmaybe 10y agoRead a little further in the README. var token = jwt.sign({ foo: 'bar' }, 'shhhhh'); var decoded = jwt.verify(token, 'shhhhh'); console.log(decoded.foo) // bar var decoded_unverified = jwt.decode(token); // NOTE: no secret! console.log(decoded_unverified.foo) // bar
- curried_haskell 10y agoYou can decode the token without the secret. Generally JWT is not encrypted and you shouldn't put sensitive info inside. But you can't modify the token without knowing the secret, because you won't have a valid signature. So I can hand out session tokens, and you can't modify the user ID or the expiration time unless you know the secret.