Hello,
I have a Django application with a large number of users, organized into groups. I use LDAP authentication, but I also need regular username/password login for some staff members and superusers, so I am using multiple authentication backends.
I implemented a custom login service that tracks failed login attempts and locks users after a certain number of retries. This approach works well for regular users, because I call the login_service in views.py, where the login forms are handled.
The problem appeared when I needed to log in through the Django admin interface. I want to keep all the default ModelAdmin functionality, but I also need to apply my custom login service there. I’m not sure what the best way to implement this would be.
I tried implementing another authentication backend to handle admin authentication, but the issue is that users who are not authenticated via LDAP or ModelBackend end up being authenticated by this custom admin backend.
Could you please give me some advice or best practices for handling this scenario?