1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

First stab at external authentication support

This commit is contained in:
Jeremy Stretch
2020-02-28 15:07:59 -05:00
parent 28e3b7af18
commit 5dc956fbe1
5 changed files with 124 additions and 4 deletions

View File

@ -1,6 +1,7 @@
from urllib import parse
from django.conf import settings
from django.contrib.auth.middleware import RemoteUserMiddleware as RemoteUserMiddleware_
from django.db import ProgrammingError
from django.http import Http404, HttpResponseRedirect
from django.urls import reverse
@ -30,6 +31,14 @@ class LoginRequiredMiddleware(object):
return self.get_response(request)
class RemoteUserMiddleware(RemoteUserMiddleware_):
"""
Custom implementation of Django's RemoteUserMiddleware which allows for a user-configurable HTTP header name.
"""
force_logout_if_no_header = False
header = settings.REMOTE_AUTH_HEADER
class APIVersionMiddleware(object):
"""
If the request is for an API endpoint, include the API version as a response header.