Fix #5460 - Log IP address for failed login
authorAndrew Browning <ayleph@thisshitistemp.com>
Tue, 15 Aug 2017 06:11:06 +0000 (02:11 -0400)
committerAndrew Browning <ayleph@thisshitistemp.com>
Wed, 20 Sep 2017 05:48:17 +0000 (01:48 -0400)
This patch logs the remote address when a login attempt fails.

mediagoblin/auth/views.py

index 2f95fd8114ae7c4e153828d916dd1be00962ad1a..fb8e72652786f58f168a8f267bc50747ae350383 100644 (file)
@@ -14,6 +14,8 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import logging
+
 import six
 
 from itsdangerous import BadSignature
@@ -29,6 +31,8 @@ from mediagoblin.tools.pluginapi import hook_handle
 from mediagoblin.auth.tools import (send_verification_email, register_user,
                                     check_login_simple)
 
+_log = logging.getLogger(__name__)
+
 
 @allow_registration
 @auth_enabled
@@ -105,6 +109,8 @@ def login(request):
                     return redirect(request, "index")
 
             login_failed = True
+            remote_addr = request.access_route[-1] or request.remote_addr
+            _log.warn("Failed login attempt from %r", remote_addr)
 
     return render_to_response(
         request,