A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: Disable auto-login for API token requests (#5094)
shamoon5576a073a5b0
diff --git a/src/paperless/auth.py b/src/paperless/auth.pyindex 2285d0526..a23b01cb4 100644--- a/src/paperless/auth.py+++ b/src/paperless/auth.py@@ -2,12 +2,16 @@ from django.conf import settingsfrom django.contrib import authfrom django.contrib.auth.middleware import PersistentRemoteUserMiddlewarefrom django.contrib.auth.models import User+from django.http import HttpRequestfrom django.utils.deprecation import MiddlewareMixinfrom rest_framework import authenticationclass AutoLoginMiddleware(MiddlewareMixin):- def process_request(self, request):+ def process_request(self, request: HttpRequest):+ # Dont use auto-login with token request+ if request.path.startswith("/api/token/") and request.method == "POST":+ return Nonetry:request.user = User.objects.get(username=settings.AUTO_LOGIN_USERNAME)auth.login(diff --git a/src/paperless/settings.py b/src/paperless/settings.pyindex 30986aaa0..2df9b83ea 100644--- a/src/paperless/settings.py+++ b/src/paperless/settings.py@@ -297,8 +297,8 @@ if DEBUG:REST_FRAMEWORK = {"DEFAULT_AUTHENTICATION_CLASSES": ["rest_framework.authentication.BasicAuthentication",- "rest_framework.authentication.SessionAuthentication","rest_framework.authentication.TokenAuthentication",+ "rest_framework.authentication.SessionAuthentication",],"DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.AcceptHeaderVersioning","DEFAULT_VERSION": "1",