mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -06:00
10653 use signal to log failed login attempts
This commit is contained in:
parent
8df162649b
commit
6f908f8cbf
8
netbox/users/apps.py
Normal file
8
netbox/users/apps.py
Normal file
@ -0,0 +1,8 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class HomeConfig(AppConfig):
|
||||
name = 'users'
|
||||
|
||||
def ready(self):
|
||||
import users.signals
|
10
netbox/users/signals.py
Normal file
10
netbox/users/signals.py
Normal file
@ -0,0 +1,10 @@
|
||||
import logging
|
||||
from django.dispatch import receiver
|
||||
from django.contrib.auth.signals import user_login_failed
|
||||
|
||||
|
||||
@receiver(user_login_failed)
|
||||
def log_user_login_failed(sender, credentials, request, **kwargs):
|
||||
logger = logging.getLogger('netbox.auth.login')
|
||||
username = credentials.get("username", None)
|
||||
logger.info(f"Failed login attempt for username: {username}")
|
Loading…
Reference in New Issue
Block a user