Use both NTLM and Anonymous authentication with IIS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
"""auth.py"""
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponse, HttpResponseRedirect

class HttpResponseNotAuthorized(HttpResponse):
    status_code = 401

    def __init__(self, *args, **kwargs):
        HttpResponse.__init__(self, *args, **kwargs)
        self['WWW-Authenticate'] = 'NegotiateNTLM'

def negotiate_ntlm(request,
                   content='You are not authorized to access this website.',
                   redirect_field_name=REDIRECT_FIELD_NAME):

    redirect_to = request.REQUEST.get(redirect_field_name, '/')

    if request.user.is_authenticated():
        return HttpResponseRedirect(redirect_to)
    else:
        return HttpResponseNotAuthorized(content)

More like this

  1. create and authenticate an anonymous user by chr15m 4 years, 7 months ago
  2. Custom mod_python AuthenHandler by aeby 6 years, 8 months ago
  3. Use custom authentication backend with admin by ungenio41 3 years, 9 months ago
  4. Django authentication for django-piston by chronos 3 years, 7 months ago
  5. Facebook Authentication Backend by barnardo 3 years, 10 months ago

Comments

(Forgotten your password?)