A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Add the possibility to customize the remote user header name
Simon Taddiken97f3c214e80e
diff --git a/docs/configuration.rst b/docs/configuration.rstindex e26180382..d182d589d 100644--- a/docs/configuration.rst+++ b/docs/configuration.rst@@ -192,7 +192,17 @@ PAPERLESS_ENABLE_HTTP_REMOTE_USER=<bool>applications.Defaults to `false` which disables this feature.-++PAPERLESS_HTTP_REMOTE_USER_HEADER_NAME=<strl>+ If `PAPERLESS_ENABLE_HTTP_REMOTE_USER` is enabled, this property allows to+ customize the name of the HTTP header from which the username is extracted.+ Values are in terms of+ [HttpRequest.META](https://docs.djangoproject.com/en/3.1/ref/request-response/#django.http.HttpRequest.META).+ Thus, the configured value must start with `HTTP_` followed by the+ normalized actual header name.++ Defaults to `HTTP_REMOTE_USER`.+.. _configuration-ocr:OCR settingsdiff --git a/src/paperless/auth.py b/src/paperless/auth.pyindex cd717e56b..3bc6344cd 100644--- a/src/paperless/auth.py+++ b/src/paperless/auth.py@@ -33,5 +33,4 @@ class HttpRemoteUserMiddleware(RemoteUserMiddleware):""" This class allows authentication via HTTP_REMOTE_USER which is set forexample by certain SSO applications."""-- header = 'HTTP_REMOTE_USER'+ header = settings.HTTP_REMOTE_USER_HEADER_NAMEdiff --git a/src/paperless/settings.py b/src/paperless/settings.pyindex 8cc12c1ff..3330da19c 100644--- a/src/paperless/settings.py+++ b/src/paperless/settings.py@@ -189,6 +189,7 @@ if AUTO_LOGIN_USERNAME:MIDDLEWARE.insert(_index+1, 'paperless.auth.AutoLoginMiddleware')ENABLE_HTTP_REMOTE_USER = __get_boolean("PAPERLESS_ENABLE_HTTP_REMOTE_USER")+HTTP_REMOTE_USER_HEADER_NAME = os.getenv("PAPERLESS_HTTP_REMOTE_USER_HEADER_NAME", "HTTP_REMOTE_USER")if ENABLE_HTTP_REMOTE_USER:MIDDLEWARE.append(