Fix #5460 - Log IP address for failed login

This patch logs the remote address when a login attempt fails.
This commit is contained in:
Andrew Browning 2017-08-15 02:11:06 -04:00
parent eee3e41bcf
commit b121d89cc5

View File

@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import six import six
from itsdangerous import BadSignature 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, from mediagoblin.auth.tools import (send_verification_email, register_user,
check_login_simple) check_login_simple)
_log = logging.getLogger(__name__)
@allow_registration @allow_registration
@auth_enabled @auth_enabled
@ -105,6 +109,8 @@ def login(request):
return redirect(request, "index") return redirect(request, "index")
login_failed = True 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( return render_to_response(
request, request,