I want to use django.contrib.auth.middleware.RemoteUserMiddleware for authentication as outlined here:
https://docs.djangoproject.com/en/dev/howto/auth-remote-user/
Question is, how can I test this in a dev environment where there is no Apache? i.e. can I set REMOTE_USER somehow in local settings?
EDIT (adding settings)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
...
)
Then I have this in my local_Settings:
os.environ['REMOTE_USER'] = "mmatyas"
I also tried the 'HTTP_REMOTE_USER' variant. Thanks!
Email authentication for Django 3.x For using email/username and password for authentication instead of the default username and password authentication, we need to override two methods of ModelBackend class: authenticate() and get_user():
Django provides an authentication and authorization ("permission") system, built on top of the session framework discussed in the previous tutorial, that allows you to verify user credentials and define what actions each user is allowed to perform.
The variable has to be set in the environment in which you start the dev server. usually it's just:
REMOTE_USER=myuser ./manage.py runserver
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With