A Django middleware that ensures every request has anauthenticated user.
A middleware that ensures that a request always has an authenticated user.
If the request doesn’t have an authenticated user, it logs in a default user. If the default user doesn’t exist, it is created.
This middleware has been tested with these versions of Django:
- master (at the time of the release)
Install from PyPI:
pip install django_always_authenticated
Add to MIDDLEWARE (MIDDLEWARE_CLASSES for Django <1.10) in settings file:
MIDDLEWARE = ( ... 'always_authenticated.middleware.AlwaysAuthenticatedMiddleware', )
As a security safeguard, the middleware will raise an ImproperlyConfiguredException when running in production mode (DEBUG=False). To run the middleware in production, set ALWAYS_AUTHENTICATED_DEBUG_ONLY to False.
This middleware reads these settings:
A string with the name of the default user, defaults to 'user'.
A dict with additional default values to set when creating the user.
Set to False to allow running with DEBUG=False.
There is a very single example project that demonstrates the middleware in the directory example_project.
To run the tests, install the requirements and run py.test:
pip install -r requirements.txt py.test
You can also use tox to run the tests with all supported versions of Python and Django:
pip install tox tox
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size django-always-authenticated-0.1.0.tar.gz (2.9 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for django-always-authenticated-0.1.0.tar.gz