News for hackers. Stuff that matters.
Re:Django 2.1 released by knicholes on Wednesday August 01, 2018 @12:05PM (#17663788)
Any tips for how to use JWT authentication and get around CSRF tokens being in forms when combining DRF with a JS SPA UI?
Re:Django 2.1 released by theptip on Wednesday August 01, 2018 @12:28PM (#17664029)
If you want JWT, you can use https://github.com/GetBlimp/django-rest-framework-jwt -- that provides another authentication class, and you can then auth with `Accept: Bearer <jwt>`.

If you don't need JWT (I'd probably leave it out next time round) then Django Rest Framework comes with a simpler bearer token auth class (among others): http://www.django-rest-framework.org/api-guide/authenticatio....

edit to add - if you're asking specifically about sharing sessions between the JS app and the Django server-side form, I believe this is what you're looking for:http://www.django-rest-framework.org/api-guide/authenticatio..., i.e. you'll still need to pass the csrf token into the JS app.

Re:Django 2.1 released by kennydude on Wednesday August 01, 2018 @12:15PM (#17663887)
The way I've always done it is to not log the user in to a Django session. That way the SPA is the thing which holds the authentication, be it JWT or any other kind of token.

If any other site tries to POST to the API on behalf of the current user they'll get a "Authentication credentials required" message.