Search code examples
pythondjangohttpauthenticationbasic-authentication

Does django natively integrate with HTTP Basic Authorization


ONe of my system components is using the Basic HTTP Authrozation ( http://en.wikipedia.org/wiki/Basic_access_authentication ) for log in information. Another part of my system is running a django application which uses the 'django.contrib.auth' app for authentication.

Would code like this work?

def urlHandler(request):
  if request.user.is_authenticated():    
     // ...

The urlHandler in this case would handle the request which has the Authorization: Basic dXNlcjpwYXNz appended to its HTTP GET. Would the django authorization backend integrate with this?

Obviously I tried the above code and it does not seem to work...

Is there a middleware that would work in this case?

Thanks


Solution

  • This has been asked and answered: Can I use HTTP Basic Authentication with Django?

    (The answer is yes. See http://docs.djangoproject.com/en/dev/howto/auth-remote-user/ for details.)