Skip to content

Commit

Permalink
log failed login attempts
Browse files Browse the repository at this point in the history
I mean like "[2014-12-13 07:22:09,573] INFO [core.signals:11] login
attempt for username 'Jennifer_Userton' failed"
  • Loading branch information
zackmdavis committed Dec 13, 2014
1 parent 4fa534e commit b2670bb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.apps import AppConfig

from core.signals import log_failed_login

class FinetoothConfig(AppConfig):
name = "core"
verbose_name = "Finetooth Core"

def ready(self):
import core.signals

default_app_config = "core.FinetoothConfig"
12 changes: 12 additions & 0 deletions core/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import logging

from django.contrib.auth.signals import user_login_failed
from django.dispatch import receiver

logger = logging.getLogger(__name__)

@receiver(user_login_failed)
def log_failed_login(sender, **kwargs):
logger.info("login attempt for username '{}' failed".format(
kwargs['credentials']['username'])
)

0 comments on commit b2670bb

Please sign in to comment.