Cookies vs JWT makes no sense. You can put the JWT in a cookie if you want to.. apples and oranges.
Cookies vs JWT makes no sense. You can put the JWT in a cookie if you want to.. apples and oranges.
Cookies: a simple session ID, a random number, stored in a cookie.
JWT: a JSON object stored in local storage that specifies authorization of some user that is authenticated by public key cryptography. JWTs can be configured in many ways, but this is what people usually mean because they want their sessions to be "stateless."
Way way more often than not, the "cookie" solution is better because it's far simpler. JWTs come with a tremendous amount of complexity with few benefits.
Sure it does, just put the JWT in the cookie ;)
Any thoughts? I can't think of anything glaringly wrong with the scheme.
Also, I generally think that if someone has the resources to obtain your JWT it probably doesn't matter if it's encrypted (assuming it's stuff like the user's ID or roles, and not something you shouldn't be putting in there anyway), because the attacker has the time until you revoke the token to do whatever they want as the user.
I'd love to hear why I'm wrong
In OP's case, I think they're unlikely to see any benefits to using JWT.
Dealing with authN/authZ can grow fairly complicated depending on the business' requirements. On the surface what you're suggesting seems like it would work perfectly fine for many use-cases, so you're not wrong.
JWT is often immaterial to authentication. One must consider how the service is consumed and through which mediums. Depending on the data's importance, you'll need to carefully consider the security model.
Acquiring someone's cookie or token doesn't always mean full access, nor does it mean you get to repeatedly request new tokens. You could require an additional password check before allowing the user to take certain actions. Two examples of this are GitHub and Google.
The big benefit I saw from JWTs was the stateless nature, with the drawback of servers using the same key.
Thanks for the reply! Sleep well.
I told them to avoid JWT and instead use old-school stateful session cookies because there's tons of libs that do most of the work for you, and they're unlikely to see any material benefits at this time from using JWT.