0

My app is required to support users logged in via SSO on a 3rd party server.

I configured settings.py based on the docs, i.e.

MIDDLEWARE_CLASSES = [
    '...',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.PersistentRemoteUserMiddleware',
    '...',
]

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.RemoteUserBackend',
]

I tried to test this using Postman on a couple of the app's URLs with no auth and with basic auth (user is defined) and, of course, with REMOTE_USER (and/or HTTP_REMOTE_USER header set). In all cases I get a 401 - unauthorized code. Moreover, the breakpoint in authenticate is never called. The process_request in the middleware is called, but the REMOTE_USER header is not in request.META.

What else do I need to configure (in Django, Postman - or better still Apache) so that the REMOTE_USER will be set? My knowledge of Apache is minimal, so a link to an example will help a lot.

The closest "solution" I saw is this, but it seems that the person circumvented the proper way to do this.

UPDATE enter image description here The Postman request is simply to one of the basic services which requires users to be logged in (@login_required decorator in Django) I've tried with both basic auth and no auth. The reply is a 401 without additional information.

>curl -i -H 'REMOTE_USER: user' localhost:9000/project/files/
HTTP/1.0 401 Unauthorized
Date: Sun, 17 Dec 2017 13:38:38 GMT
Server: WSGIServer/0.1 Python/2.7.10
Expires: Sun, 17 Dec 2017 13:38:38 GMT
Vary: Cookie
Last-Modified: Sun, 17 Dec 2017 13:38:38 GMT
Location: /accounts/login/?next=/project/files/
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=utf-8

Same command with cURL. The Location seems to suggest it tried to redirect to the login page (which should not happen)

mibm
  • 1,328
  • 2
  • 13
  • 23
  • Can you provide a sample of the request? (perhaps the CURL equivalent) And a sample of the response? – Ed Meacham Dec 15 '17 at 19:27
  • @EdMeacham I updated the question with the Postman query and 401 reply (no details given). Can you point me to an example of how to use REMOTE_USER properly? – mibm Dec 17 '17 at 09:15

0 Answers0