From 44cd8565b14f2069a7c5fddd8390f5c70c3bc321 Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Mon, 9 Nov 2020 15:28:45 +0100 Subject: [PATCH] removed no-login option since it wasn't working with the new django version anyway. --- paperless.conf.example | 5 ----- src/paperless/middleware.py | 14 -------------- src/paperless/models.py | 31 ------------------------------- src/paperless/settings.py | 5 ----- 4 files changed, 55 deletions(-) delete mode 100644 src/paperless/middleware.py delete mode 100644 src/paperless/models.py diff --git a/paperless.conf.example b/paperless.conf.example index bd9f715f2..9c0b57250 100644 --- a/paperless.conf.example +++ b/paperless.conf.example @@ -129,11 +129,6 @@ PAPERLESS_EMAIL_SECRET="" # https://docs.djangoproject.com/en/1.11/ref/settings/#force-script-name #PAPERLESS_FORCE_SCRIPT_NAME="" -# If you are using alternative authentication means or are just using paperless -# as a single user on a small private network, this option allows you to disable -# user authentication if you set it to "true" -#PAPERLESS_DISABLE_LOGIN="false" - ############################################################################### #### Software Tweaks #### ############################################################################### diff --git a/src/paperless/middleware.py b/src/paperless/middleware.py deleted file mode 100644 index 58cdad65c..000000000 --- a/src/paperless/middleware.py +++ /dev/null @@ -1,14 +0,0 @@ -from django.utils.deprecation import MiddlewareMixin -from .models import User - - -class Middleware(MiddlewareMixin): - """ - This is a dummy authentication middleware class that creates what - is roughly an Anonymous authenticated user so we can disable login - and not interfere with existing user ID's. It's only used if - login is disabled in paperless.conf (default is to require login) - """ - - def process_request(self, request): - request.user = User() diff --git a/src/paperless/models.py b/src/paperless/models.py deleted file mode 100644 index e390032db..000000000 --- a/src/paperless/models.py +++ /dev/null @@ -1,31 +0,0 @@ -from django.contrib.auth.models import User as DjangoUser - - -class User: - """ - This is a dummy django User used with our middleware to disable - login authentication if that is configured in paperless.conf - """ - - is_superuser = True - is_active = True - is_staff = True - is_authenticated = True - - @property - def id(self): - return DjangoUser.objects.order_by("pk").first().pk - - @property - def pk(self): - return self.id - - -""" -NOTE: These are here as a hack instead of being in the User definition -NOTE: above due to the way pycodestyle handles lamdbdas. -NOTE: See https://github.com/PyCQA/pycodestyle/issues/379 for more. -""" - -User.has_module_perms = lambda *_: True -User.has_perm = lambda *_: True diff --git a/src/paperless/settings.py b/src/paperless/settings.py index aa356aa5a..65da01218 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -140,11 +140,6 @@ def __get_boolean(key, default="NO"): # Allow access from the angular development server during debugging CORS_ORIGIN_WHITELIST += ('http://localhost:4200',) -# If auth is disabled, we just use our "bypass" authentication middleware -if bool(os.getenv("PAPERLESS_DISABLE_LOGIN", "false").lower() in ("yes", "y", "1", "t", "true")): - _index = MIDDLEWARE.index("django.contrib.auth.middleware.AuthenticationMiddleware") - MIDDLEWARE[_index] = "paperless.middleware.Middleware" - # The secret key has a default that should be fine so long as you're hosting # Paperless on a closed network. However, if you're putting this anywhere # public, you should change the key to something unique and verbose.