0

i have a django web app installed and hosted on IIS on server . Currently it is not provided with any authentication , but i want to give it windows authentication so that if anyone tries to access the url should provide windows username and password .

made a small research on this topic and as am new towards this authentication using windows i want someone's help .

So the first step i did was to modify settings.py file of Django project . As seen on question https://stackoverflow.com/questions/26881344/django-authenticate-using-logged-in-windows-domain-user

i added

MIDDLEWARE_CLASSES = (
    ...
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.RemoteUserMiddleware',
    ...
)

and

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

to settings.py . and next i migrated the app and ran server . restarted the app .

and as per the answer for the above stack qustion it required changing or enabling of windows authentication on IIS . did as per the instruction from the answer provided in the above stack question

but the issue is no error am getting and no login using windows . it runs as usual without any authentication

Is there any other way to do this . Can anyone help me on this stuff

1 Answers1

1

Django project deployed to IIS we can use the windows authentication in IIS.

First make sure that IIS has installed windows authentication:

enter image description here

Choose Authentication in Django site:

enter image description here

Disable all other authentications and enable windows authentication:

enter image description here

When we access the Django site, we need to enter the windows credentials:

enter image description here

Feel free to let me know if there are any questions.

Ding Peng
  • 3,702
  • 1
  • 5
  • 8
  • yeah , but i am not getting it , is that the above code enough for django to authenticate using windows or should i do anything apart from it – Niranjana Neeranj Feb 07 '21 at 05:40
  • like should i set anything while publishing it on IIS , or anything like that . since i did the same thing on server where the code is deployed , but it was not showing windows authentication. Is there any way u can explain me this – Niranjana Neeranj Feb 07 '21 at 05:42
  • The above steps have allowed Django to use windows to verify that you do not need to do anything else. The operations above are all based on IIS. We use the built-in windows authentication of IIS to protect the Django website. – Ding Peng Feb 07 '21 at 05:51
  • I don’t know much about django applications, but the above operations can be applied to any site, not just django applications. – Ding Peng Feb 07 '21 at 05:53
  • Oh Okay so are you saying that not code in Django is required and just i need to do it on IIS and nothing to be added or deleted from code – Niranjana Neeranj Feb 07 '21 at 05:53
  • Yes, We don't need to configure any code in Django. – Ding Peng Feb 07 '21 at 05:54
  • Let me check that way – Niranjana Neeranj Feb 07 '21 at 05:58
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/228364/discussion-between-niranjana-neeranj-and-ding-peng). – Niranjana Neeranj Feb 07 '21 at 08:13