The sesame.middleware.AuthenticationMiddleware provides site-wide authentication. When a valid token is found in a URL, the user is logged in automatically, and the token is removed from the URL via an HTTP 302 Redirect. This allows users to access views protected by login_required or LoginRequiredMixin using a single click.
Setup:
Add the middleware to your MIDDLEWARE setting immediately after Django's built-in AuthenticationMiddleware.
Note for Safari users:
You must install the ua extra to ensure compatibility with Safari:
pip install 'django-sesame[ua]'
MIDDLEWARE = [
...,
"django.contrib.auth.middleware.AuthenticationMiddleware",
"sesame.middleware.AuthenticationMiddleware",
...,
]