Ticket #5460: 0001-Fix-5460-Log-IP-address-for-failed-login.patch

File 0001-Fix-5460-Log-IP-address-for-failed-login.patch, 1.3 KB (added by ayleph, 7 years ago)
  • mediagoblin/auth/views.py

    From 32cb8a2545403c46c67a572e0a61af2d9f77d160 Mon Sep 17 00:00:00 2001
    From: Andrew Browning <ayleph@thisshitistemp.com>
    Date: Tue, 15 Aug 2017 02:11:06 -0400
    Subject: [PATCH] Fix #5460 - Log IP address for failed login
    
    This patch logs the remote address when a login attempt fails.
    ---
     mediagoblin/auth/views.py | 6 ++++++
     1 file changed, 6 insertions(+)
    
    diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py
    index 2f95fd81..fb8e7265 100644
    a b  
    1414# You should have received a copy of the GNU Affero General Public License
    1515# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1616
     17import logging
     18
    1719import six
    1820
    1921from itsdangerous import BadSignature
    from mediagoblin.tools.pluginapi import hook_handle  
    2931from mediagoblin.auth.tools import (send_verification_email, register_user,
    3032                                    check_login_simple)
    3133
     34_log = logging.getLogger(__name__)
     35
    3236
    3337@allow_registration
    3438@auth_enabled
    def login(request):  
    105109                    return redirect(request, "index")
    106110
    107111            login_failed = True
     112            remote_addr = request.access_route[-1] or request.remote_addr
     113            _log.warn("Failed login attempt from %r", remote_addr)
    108114
    109115    return render_to_response(
    110116        request,