Skip to content

Instantly share code, notes, and snippets.

@twolfson
Created October 26, 2023 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twolfson/95fd75bfb6b378668103814caff6e40f to your computer and use it in GitHub Desktop.
Save twolfson/95fd75bfb6b378668103814caff6e40f to your computer and use it in GitHub Desktop.
Django <> React cookie based authentication example

This is a gist for easier discover and pointing to a buried repo

In my explorations for https://github.com/twolfson/if-i-were-to-build-a-startup-web-app, I created a demo repo with:

  • Django
  • django-allauth (so you don't have to create all your auth from scratch, as so many demos require)
  • React

The repo is: https://github.com/twolfson/if-i-were-to-build-a-startup-web-app/tree/main/explorations/4-django-allauth-react-proxy

Additionally, it has security best practices like cookies, with HttpOnly and SameSite

I don't actually recommend this setup as your first choice for a startup, since you're reimplementing an API to be the only consumer of.

But if you're overly enthusiastic about it, it's your best bet for rapid standup, with progressive introduction of React based auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment