From b56a4a0c46e71a2363735d8abd0312aeb6eb4b28 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Thu, 6 Jul 2017 22:29:01 +0100 Subject: [PATCH] Log a message when an IP is blacklisted --- authserv/app_common.py | 3 ++- authserv/ratelimit.py | 6 ++++-- debian/changelog | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/authserv/app_common.py b/authserv/app_common.py index de8a4fa..788b3a2 100644 --- a/authserv/app_common.py +++ b/authserv/app_common.py @@ -95,6 +95,7 @@ def _do_auth(mc, username, service, shard, password, otp_token, source_ip, bl.auth_failure('u', username) if (source_ip and not whitelisted(source_ip, current_app.config.get('SOURCE_IP_WHITELIST'))): - bl.auth_failure('ip', source_ip) + if bl.auth_failure('ip', source_ip): + current_app.logger.info('blacklisted IP %s', source_ip) return (retval, errmsg, out_shard) diff --git a/authserv/ratelimit.py b/authserv/ratelimit.py index 43529b6..d549cca 100644 --- a/authserv/ratelimit.py +++ b/authserv/ratelimit.py @@ -63,7 +63,7 @@ class RateLimit(object): except: result = None if result is None: - # Memcache is failing. + # Memcache is failing. Fail open. return True return result <= self.count @@ -98,6 +98,8 @@ class BlackList(object): key = _tostr(self.prefix + key) if not self.rl.check(mc, key): mc.set(key, 'true', time=self.ttl) + return True + return False class AuthBlackList(object): @@ -116,4 +118,4 @@ class AuthBlackList(object): if not value: return key = key_sep.join([tag, value]) - self.blacklist.incr(self.mc, key) + return self.blacklist.incr(self.mc, key) diff --git a/debian/changelog b/debian/changelog index 79b1ec5..6bf1f0f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +authserv (0.1.2) unstable; urgency=medium + + * Fixed memcache connection errors. + + -- Autistici/Inventati <debian@autistici.org> Thu, 06 Jul 2017 22:16:55 +0100 + authserv (0.1.1) unstable; urgency=medium * Systemd support. -- GitLab