Write a thin wrapper around the standard Django auth backend

This commit is contained in:
Jeff Bradberry
2021-05-07 14:37:39 -04:00
parent 26b7e9de40
commit 5c664eadf9
3 changed files with 16 additions and 1 deletions

14
awx/main/backends.py Normal file
View File

@@ -0,0 +1,14 @@
import logging
from django.conf import settings
from django.contrib.auth.backends import ModelBackend
logger = logging.getLogger('awx.main.backends')
class AWXModelBackend(ModelBackend):
def authenticate(self, request, **kwargs):
if settings.DISABLE_LOCAL_AUTH:
logger.warning(f"User '{kwargs['username']}' attempted login through the disabled local authentication system.")
return
return super().authenticate(request, **kwargs)