A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Transition to new library for finding IPs from the Django request
Trenton H17144c45e5fb
diff --git a/Pipfile b/Pipfileindex f9d40625a..7707a8cdd 100644--- a/Pipfile+++ b/Pipfile@@ -21,7 +21,6 @@ django-extensions = "*"django-filter = "~=22.1"djangorestframework = "~=3.14"djangorestframework-guardian = "*"-django-ipware = "*"filelock = "*"gunicorn = "*"imap-tools = "*"@@ -33,6 +32,7 @@ python-gnupg = "*"python-dotenv = "*"python-dateutil = "*"python-magic = "*"+python-ipware = "*"psycopg2 = "*"rapidfuzz = "*"redis = {extras = ["hiredis"], version = "*"}@@ -51,7 +51,6 @@ channels = "~=3.0"channels-redis = "*"uvicorn = {extras = ["standard"], version = "*"}concurrent-log-handler = "*"-pyzbar = "*"mysqlclient = "*"celery = {extras = ["redis"], version = "*"}diff --git a/Pipfile.lock b/Pipfile.lockindex 02ca70283..47bd4364e 100644--- a/Pipfile.lock+++ b/Pipfile.lock@@ -1,7 +1,7 @@{"_meta": {"hash": {- "sha256": "8fecf74dce093fa66c1027ae9230da1afb1c61d80eab7264823884e005e7284b"+ "sha256": "6aeae592dcf1d7737a6cb6886db1ff7387a9daf3796f782531d25f2e22d608d9"},"pipfile-spec": 6,"requires": {},@@ -543,14 +543,6 @@"index": "pypi","version": "==2.4.0"},- "django-ipware": {- "hashes": [- "sha256:4fa5607ee85e12ee5e158bc7569ff1e134fb1579681aa1ff3f0ed04be21be153",- "sha256:80b52a3f571a371519cc552798f1015b934dd5dd7738bfad87e101e861bd21b8"- ],- "index": "pypi",- "version": "==5.0.0"- },"djangorestframework": {"hashes": ["sha256:579a333e6256b09489cbe0a067e66abe55c6595d8926be6b99423786334350c8",@@ -1301,6 +1293,14 @@"index": "pypi","version": "==0.5.0"},+ "python-ipware": {+ "hashes": [+ "sha256:01b9fa589521c29d7573f69fc4855c6b95687f0029601b78fffef1eb17f1de27",+ "sha256:ee84cd16c2cf862faae197ad5f8fae6c75e4b1f40bb13357944a5d63ddc2a373"+ ],+ "index": "pypi",+ "version": "==0.9.0"+ },"python-magic": {"hashes": ["sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b",diff --git a/src/paperless/signals.py b/src/paperless/signals.pyindex 40e2682dd..83ba74193 100644--- a/src/paperless/signals.py+++ b/src/paperless/signals.py@@ -1,24 +1,25 @@import loggingfrom django.conf import settings-from ipware import get_client_ip+from ipware import IpWarelogger = logging.getLogger("paperless.auth")# https://docs.djangoproject.com/en/4.1/ref/contrib/auth/#django.contrib.auth.signals.user_login_faileddef handle_failed_login(sender, credentials, request, **kwargs):- client_ip, is_routable = get_client_ip(- request,- proxy_trusted_ips=settings.TRUSTED_PROXIES,+ ipware = IpWare(proxy_trusted_list=settings.TRUSTED_PROXIES)+ client_ip, _ = ipware.get_client_ip(+ meta=request.META,)+if client_ip is None:logger.info(f"Login failed for user `{credentials['username']}`."" Unable to determine IP address.",)else:- if is_routable:+ if client_ip.is_global:# We got the client's IP addresslogger.info(f"Login failed for user `{credentials['username']}`"