django-filter = "~=22.1"
djangorestframework = "~=3.14"
djangorestframework-guardian = "*"
-django-ipware = "*"
filelock = "*"
gunicorn = "*"
imap-tools = "*"
python-dotenv = "*"
python-dateutil = "*"
python-magic = "*"
+python-ipware = "*"
psycopg2 = "*"
rapidfuzz = "*"
redis = {extras = ["hiredis"], version = "*"}
channels-redis = "*"
uvicorn = {extras = ["standard"], version = "*"}
concurrent-log-handler = "*"
-
pyzbar = "*"
mysqlclient = "*"
celery = {extras = ["redis"], version = "*"}
{
"_meta": {
"hash": {
- "sha256": "8fecf74dce093fa66c1027ae9230da1afb1c61d80eab7264823884e005e7284b"
+ "sha256": "6aeae592dcf1d7737a6cb6886db1ff7387a9daf3796f782531d25f2e22d608d9"
},
"pipfile-spec": 6,
"requires": {},
"index": "pypi",
"version": "==2.4.0"
},
- "django-ipware": {
- "hashes": [
- "sha256:4fa5607ee85e12ee5e158bc7569ff1e134fb1579681aa1ff3f0ed04be21be153",
- "sha256:80b52a3f571a371519cc552798f1015b934dd5dd7738bfad87e101e861bd21b8"
- ],
- "index": "pypi",
- "version": "==5.0.0"
- },
"djangorestframework": {
"hashes": [
"sha256:579a333e6256b09489cbe0a067e66abe55c6595d8926be6b99423786334350c8",
"index": "pypi",
"version": "==0.5.0"
},
+ "python-ipware": {
+ "hashes": [
+ "sha256:01b9fa589521c29d7573f69fc4855c6b95687f0029601b78fffef1eb17f1de27",
+ "sha256:ee84cd16c2cf862faae197ad5f8fae6c75e4b1f40bb13357944a5d63ddc2a373"
+ ],
+ "index": "pypi",
+ "version": "==0.9.0"
+ },
"python-magic": {
"hashes": [
"sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b",
import logging
from django.conf import settings
-from ipware import get_client_ip
+from ipware import IpWare
logger = logging.getLogger("paperless.auth")
# https://docs.djangoproject.com/en/4.1/ref/contrib/auth/#django.contrib.auth.signals.user_login_failed
def 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 address
logger.info(
f"Login failed for user `{credentials['username']}`"