[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#922458: python3-x2gobroker: base_broker does not log IP of authentication attempts



Package: python3-x2gobroker
Version: 0.0.4.0-3

x2gobroker.brokers.base_broker.X2GoBroker.check_access does not log
authentication attempts together with IP (and username), and thus can't
be used together with e.g. fail2ban. I have attached a patch which adds
this logging.
diff --git a/x2gobroker/brokers/base_broker.py b/x2gobroker/brokers/base_broker.py
index bccc91e..6f959eb 100644
--- a/x2gobroker/brokers/base_broker.py
+++ b/x2gobroker/brokers/base_broker.py
@@ -981,9 +981,8 @@ class X2GoBroker(object):
                 ###
                 ###
 
-                logger_broker.debug('base_broker.X2GoBroker.check_access(): checking for valid authentication: {access}'.format(access=access))
-
                 if access:
+                    logger_broker.warning('base_broker.X2GoBroker.check_access(): authentication succeeded for user {username} at ip {ip}'.format(username=username, ip=ip))
                     #create new cookie for this user
                     #each user gets one or more tuples of IP, time stored as username_UUID files so they can connect from multiple sessions
                     next_cookie = str(uuid.uuid4())
@@ -994,6 +993,8 @@ class X2GoBroker(object):
                     if cookie_directory and username and cookie:
                         os.remove(cookie_directory+"/"+username+"_"+cookie)
                     logger_broker.debug('base_broker.X2GoBroker.check_access(): Giving new cookie: {cookie} to user {username} at ip {ip}'.format(cookie=next_cookie,username=username,ip=ip))
+                else:
+                    logger_broker.warning('base_broker.X2GoBroker.check_access(): authentication failed for user {username} at ip {ip}'.format(username=username, ip=ip))
 
             else:
                 # there is a cookie but its not ours so its either wrong or subsequent password auth

Reply to: