Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Updating changes to allow for disabling login

Matt Meno516bc48a3310
diff --git a/paperless.conf.example b/paperless.conf.example
index b197b1a12..a7af84ff0 100644
--- a/paperless.conf.example
+++ b/paperless.conf.example
@@ -86,6 +86,11 @@ PAPERLESS_PASSPHRASE="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=""
+
###############################################################################
#### Software Tweaks ####
###############################################################################
diff --git a/src/paperless/auto_auth.py b/src/paperless/auto_auth.py
index 27d9158c1..f4b908c7d 100644
--- a/src/paperless/auto_auth.py
+++ b/src/paperless/auto_auth.py
@@ -1,10 +1,18 @@
from django.contrib.auth.models import User
+'''
+ This is a dummy authentication middleware module that creates what
+ is roughly an Anonymous authenticated user so we can disable login
+ and not interfere with existing user ID's.
+'''
+
class User:
is_superuser = True
is_active = True
is_staff = True
- id = 1
+ is_authenticated=True
+ id = -1 #Must be -1 to avoid colliding with possible existing user ID's (that start number at 1)
+ pk = -1
def return_true(*args, **kwargs):
return True
diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index a28424e81..ec7449f64 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -78,12 +78,14 @@ if os.getenv("PAPERLESS_INSTALLED_APPS"):
INSTALLED_APPS += os.getenv("PAPERLESS_INSTALLED_APPS").split(",")
+#Default Django authentication middleware (requires a username/password)
AUTH_CLASSES = [\
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware']
-if bool(os.getenv("PAPERLESS_DISABLE_AUTH","true").lower() in ("yes", "y", "1", "t", "true")):
- AUTH_CLASSES = ['auto_auth.Middleware']
+#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")):
+ AUTH_CLASSES = ['paperless.auto_auth.Middleware']
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',