From 306c4db3cd9272d4252d0858035001e514976e92 Mon Sep 17 00:00:00 2001 From: Kendar Date: Fri, 28 May 2021 12:37:34 +0200 Subject: [PATCH] Working --- webvirtcloud/ldapbackend.py | 8 ++++++-- webvirtcloud/settings.py.template | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/webvirtcloud/ldapbackend.py b/webvirtcloud/ldapbackend.py index 6d0e227..88d7147 100644 --- a/webvirtcloud/ldapbackend.py +++ b/webvirtcloud/ldapbackend.py @@ -35,7 +35,9 @@ class LdapAuthenticationBackend(ModelBackend): return None def authenticate(self, request, username=None, password=None, **kwargs): - print("authenticate") + if not settings.LDAP_ENABLED: + return None + print("authenticate_ldap") # Get the user information from the LDAP if he can be authenticated isAdmin = False isStaff = False @@ -97,7 +99,9 @@ class LdapAuthenticationBackend(ModelBackend): return user def get_user(self, user_id): - print("get_user") + if not settings.LDAP_ENABLED: + return None + print("get_user_ldap") try: return User.objects.get(pk=user_id) except User.DoesNotExist: diff --git a/webvirtcloud/settings.py.template b/webvirtcloud/settings.py.template index 57d9c49..7f7ef10 100644 --- a/webvirtcloud/settings.py.template +++ b/webvirtcloud/settings.py.template @@ -214,6 +214,7 @@ OTP_ENABLED = False LOGIN_REQUIRED_IGNORE_VIEW_NAMES = ["accounts:email_otp"] +LDAP_ENABLED = False LDAP_URL = '192.168.1.67' LDAP_PORT = 389 USE_SSL = False