0

I am trying to just have simple, WWW-Authenticate HTTP authentication in Django using REMOTE_USER. This is done with RemoteUserMiddleware.

Unfortunately, after changing my config file like such:

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.RemoteUserMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

AUTHENTICATION_BACKENDS = ( 
    'django.contrib.auth.backends.RemoteUserBackend',
)

and adding @login_required decorator to my view, it is not working. When I view the page, it directs me to accounts/login/?next=/page/I/tried/to/access, which doesn't exist and raises a 404 error.

Why doesn't it just send WWW-Authenticate? If this isn't the right way to do that, how can I?

Fredrick Brennan
  • 7,079
  • 2
  • 30
  • 61
  • 1
    `RemoteUserMiddleware` isn't used to implement basic authentication, it's used to handle people who logged on using basic authentication by some other source (like Apache configured to use htpasswd). Django doesn't support basic authentication out of the box, but [django-basic](http://code.google.com/p/django-basic/) says it can provide it. – robertklep Mar 16 '13 at 19:31
  • 1
    @robertklep Thanks for your answer, I was able to use it after adding a `Location` directive in Apache with `AuthType Basic` and the rest. I misunderstood what the middleware was actually for. – Fredrick Brennan Mar 16 '13 at 22:09

0 Answers0