mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Write a thin wrapper around the standard Django auth backend
This commit is contained in:
14
awx/main/backends.py
Normal file
14
awx/main/backends.py
Normal 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)
|
||||||
@@ -364,7 +364,7 @@ AUTHENTICATION_BACKENDS = (
|
|||||||
'social_core.backends.github_enterprise.GithubEnterpriseTeamOAuth2',
|
'social_core.backends.github_enterprise.GithubEnterpriseTeamOAuth2',
|
||||||
'social_core.backends.azuread.AzureADOAuth2',
|
'social_core.backends.azuread.AzureADOAuth2',
|
||||||
'awx.sso.backends.SAMLAuth',
|
'awx.sso.backends.SAMLAuth',
|
||||||
'django.contrib.auth.backends.ModelBackend',
|
'awx.main.backends.AWXModelBackend',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ class AuthenticationBackendsField(fields.StringListField):
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
('django.contrib.auth.backends.ModelBackend', []),
|
('django.contrib.auth.backends.ModelBackend', []),
|
||||||
|
('awx.main.backends.AWXModelBackend', []),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user