django - Admin redirects to /login although REMOTE_USER is provided -


i configured authentication using remote_user in django project, replacing default modelbackend. however, when call admin page still redirects login page. tested with:

curl -i -h 'remote_user: ruser1' http://localhost:8765/admin/myapp/mytable/ location: http://localhost:8765/admin/login/?next=/admin/myapp/mytable/ 

[edit: wrong - tested remote_user=ruser1 ./manage.py runserver]

the remote user has been added auth_user table.

my related config snippets are:

middleware_classes = (     ...     'django.contrib.auth.middleware.authenticationmiddleware',     'django.contrib.auth.middleware.remoteusermiddleware',      'django.contrib.auth.middleware.sessionauthenticationmiddleware',     ... ) authentication_backends = (     'django.contrib.auth.backends.remoteuserbackend', ) 

you can't set remote_user http header, otherwise users able spoof header , log in user wanted.

in production, remote_user environment variable set server, e.g. apache or nginx. if testing using development server, can set remote user with

remote_user=ruser1 ./manage.py runserver 

any requests dev server processed ruser1 logged in user.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -