Earlier quoted context omitted.
Is this really about buzzwords or a lack of understanding of the technology choices? Django Sessions is equivalent to stateful JWT authentication. Your choice of using one over the other depends on your constraints. But if I needed a session's based solution, I'd probably go with a stateful JWT implementation rather than Django own session. That is unless I am building a really basic app, and looking to get done with…
There is no reason to use JWT in this case. Because you trust your session store, right? The only benefit of JWT is when you can't trust the "hands" the token passed through. Otherwise just use JSON... Not sure what "stateful JWT authentication" is supposed to be anyway...
Authentication with Django and Single Page Apps (2020)
31–39 of 39 posts
Re: Authentication with Django and Single Page Apps (2020)
#32> JWTs are vulnerable to brute force attacks once intercepted. On the linked PDF it says: > Shorter keys can be brute forced. Yeah... don't use short keys. And then also misquotes: > JWT token cannot be invalidated by itself JWT _can_ be invalidated, you just need to somehow store the invalidated tokens, depending on the use case this can make sense, since the number of invalidated tokens is going to be way smaller.…
Re: Authentication with Django and Single Page Apps (2020)
#33Earlier quoted context omitted.
There is no reason to use JWT in this case. Because you trust your session store, right? The only benefit of JWT is when you can't trust the "hands" the token passed through. Otherwise just use JSON... Not sure what "stateful JWT authentication" is supposed to be anyway...
I think I can kind of understand one advantage of using state-backed JWTs, if I got the idea right: double validation, both client and server side. So client side you get immediate validation of regular expiry and various other attributes without contacting the server. There’s a slight performance boost for the server in some circumstances, traded for always more client side work.
Another option is a signed or encrypted cookie containing whatever you want it to store. That is similar to a session store but stored on the client side and quite limited in size. Again, that's not really JWT, but you may use a JWT as a cookie if you have to. But JWT isn't encrypted (by default).
Re: Authentication with Django and Single Page Apps (2020)
#34Earlier quoted context omitted.
I think I can kind of understand one advantage of using state-backed JWTs, if I got the idea right: double validation, both client and server side. So client side you get immediate validation of regular expiry and various other attributes without contacting the server. There’s a slight performance boost for the server in some circumstances, traded for always more client side work.
JWT is nothing but a signed JSON. You only sign it because you need some entity to trust it without asking another server. If you need to ask another server, you don't need JWT. And that's what the Django session store is doing. The data isn't stored on the client side. Another option is a signed or encrypted cookie containing whatever you want it to store. That is similar to a session store but stored on the client…
Re: Authentication with Django and Single Page Apps (2020)
#35Earlier quoted context omitted.
But that's true of session auth as well. The only necessary check is "does this session token exist and have a creation date within the expiry period", which should be a single, fairly quick database query for all but the most extreme "at scale" cases. You should not need multiple round trips to validate that. The main use cases for JWT are: * I want to create a session token that I _never_ want to revalidate against…
> I want to create a session token that I _never_ want to revalidate against a database There's the middle ground as well with a long lived authentication or refresh token and a short lived authorization token. > I want to include role (or other) information directly in the token for the sake of convenience Once I started seriously developing cloud solutions, this became indispensable. It's not just convenient, it di…
JWT tokens definitely have their place, I don't want to imply that they're useless. They're a tool with tradeoffs like every other tool we use. But I've seen a lot of projects using them without understanding those tradeoffs, and then creating either very inefficient, overly complex, or subtly insecure applications as a result.
Re: Authentication with Django and Single Page Apps (2020)
#36Earlier quoted context omitted.
The use of trusted jwt libraries which outsource registration and authentication has massive benefits such as SSO and reducing the risk of vulnerabilities (user reg/auth being handled by a dedicated party). There’s no reliance on a database or state management, which can be useful under some conditions. In my eyes, the problem is reliance of the authorisation header instead of cookies, this has some benefits but is a…
How is your first paragraph a result of using JWT over sessions?
You could technically use SSO with any other auth token, or exchange it during the auth process, but ultimately having metadata about the user in near clear text is useful.
Don’t get me wrong, I think jwt and the rest of websec is a total fucking mess, but jwt is far from the worst offender.
Re: Authentication with Django and Single Page Apps (2020)
#37is there an implicit assumption that we're operating on the same domain here for the frontend and backend I'm not sure that it's so easily handled if you're working from www.foo.com and api.foo.com
If the API tries to set an HTTPS-only session cookie on api.example.com, the client/browser will simply forward cookie that on every request (including requests made on behalf of a user like a frontend calling fetch()). You can try this yourself, or see it happening in the Github example linked in the post.
If you had backend APIs supported by different domains (api1.example.com and api2.example.com), things do get more troublesome. You could still configure the cookie domain for .example.com, but then you're sending the session cookie along with any request to any example.com subdomain.
Re: Authentication with Django and Single Page Apps (2020)
#38> localStorage or sessionStorage, both of which are 100% insecure. This makes me doubt everything else he says.
Re: Authentication with Django and Single Page Apps (2020)
#39Earlier quoted context omitted.
But that's true of session auth as well. The only necessary check is "does this session token exist and have a creation date within the expiry period", which should be a single, fairly quick database query for all but the most extreme "at scale" cases. You should not need multiple round trips to validate that. The main use cases for JWT are: * I want to create a session token that I _never_ want to revalidate against…
> I want to create a session token that I _never_ want to revalidate against a database There's the middle ground as well with a long lived authentication or refresh token and a short lived authorization token. > I want to include role (or other) information directly in the token for the sake of convenience Once I started seriously developing cloud solutions, this became indispensable. It's not just convenient, it di…
This works up until a certain point. Once you get past simple RBAC to more fine-grained (resource-based) authz, jwts don't scale: https://medium.com/building-carta/authz-cartas-highly-scalab...