A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Allow authentication via HTTP_REMOTE_USER
Michael Shamoon7b56ad9dad62
diff --git a/docs/configuration.rst b/docs/configuration.rstindex 5ccb80b3a..c72027574 100644--- a/docs/configuration.rst+++ b/docs/configuration.rst@@ -162,6 +162,12 @@ PAPERLESS_COOKIE_PREFIX=<str>Defaults to ``""``, which does not alter the cookie names.+PAPERLESS_ENABLE_HTTP_REMOTE_USER=<bool>+ Allows authentication via HTTP_REMOTE_USER which is used by some SSO+ applications.++ Defaults to `false` which disables this feature.+.. _configuration-ocr:OCR settings@@ -210,20 +216,20 @@ PAPERLESS_OCR_MODE=<mode>into images and puts the OCRed text on top. This works for all documents,however, the resulting document may be significantly larger and textwon't appear as sharp when zoomed in.-+The default is ``skip``, which only performs OCR when necessary and alwayscreates archived documents.PAPERLESS_OCR_OUTPUT_TYPE=<type>Specify the the type of PDF documents that paperless should produce.-+* ``pdf``: Modify the PDF document as little as possible.* ``pdfa``: Convert PDF documents into PDF/A-2b documents, which is asubset of the entire PDF specification and meant for storingdocuments long term.* ``pdfa-1``, ``pdfa-2``, ``pdfa-3`` to specify the exact version ofPDF/A you wish to use.-+If not specified, ``pdfa`` is used. Remember that paperless also keepsthe original input file as well as the archived version.@@ -275,9 +281,9 @@ PAPERLESS_OCR_USER_ARG=<json>.. code:: json- {"deskew": true, "optimize": 3, "unpaper_args": "--pre-rotate 90"}--+ {"deskew": true, "optimize": 3, "unpaper_args": "--pre-rotate 90"}++Software tweaks###############diff --git a/paperless.conf.example b/paperless.conf.exampleindex 139453cf3..c55b7f5f4 100644--- a/paperless.conf.example+++ b/paperless.conf.example@@ -31,6 +31,7 @@#PAPERLESS_STATIC_URL=/static/#PAPERLESS_AUTO_LOGIN_USERNAME=#PAPERLESS_COOKIE_PREFIX=+#PAPERLESS_ENABLE_HTTP_REMOTE_USER=false# OCR settingsdiff --git a/src/paperless/auth.py b/src/paperless/auth.pyindex ece5d0eba..d92dc7671 100644--- a/src/paperless/auth.py+++ b/src/paperless/auth.py@@ -2,6 +2,7 @@ from django.conf import settingsfrom django.contrib.auth.models import Userfrom django.utils.deprecation import MiddlewareMixinfrom rest_framework import authentication+from rest_framework import exceptionsclass AutoLoginMiddleware(MiddlewareMixin):@@ -26,3 +27,21 @@ class AngularApiAuthenticationOverride(authentication.BaseAuthentication):return (user, None)else:return None+++class HttpRemoteUserAuthentication(authentication.BaseAuthentication):+ """ This class allows authentication via HTTP_REMOTE_USER which is set for+ example by certain SSO applications.+ """++ def authenticate(self, request):+ username = request.META.get('HTTP_REMOTE_USER')+ if not username:+ return None++ try:+ user = User.objects.get(username=username)+ except User.DoesNotExist:+ raise exceptions.AuthenticationFailed('No such user')++ return (user, None)diff --git a/src/paperless/settings.py b/src/paperless/settings.pyindex 5af1be85e..f522c4c0b 100644--- a/src/paperless/settings.py+++ b/src/paperless/settings.py@@ -112,6 +112,13 @@ if DEBUG:'paperless.auth.AngularApiAuthenticationOverride')+ENABLE_HTTP_REMOTE_USER = __get_boolean("PAPERLESS_ENABLE_HTTP_REMOTE_USER")++if ENABLE_HTTP_REMOTE_USER:+ REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'].append(+ 'paperless.auth.HttpRemoteUserAuthentication'+ )+MIDDLEWARE = ['django.middleware.security.SecurityMiddleware','whitenoise.middleware.WhiteNoiseMiddleware',