mirror of
https://github.com/retspen/webvirtcloud
synced 2026-03-22 02:24:56 +00:00
Update
This commit is contained in:
parent
557594769d
commit
50c1bc4b29
2 changed files with 8 additions and 8 deletions
|
|
@ -31,21 +31,21 @@ class LdapAuthenticationBackend(ModelBackend):
|
||||||
|
|
||||||
return connection.response[0]
|
return connection.response[0]
|
||||||
except:
|
except:
|
||||||
print('get_LDAP_user-error')
|
print('get_LDAP_user-error')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def authenticate(self, request, username=None, password=None, **kwargs):
|
def authenticate(self, request, username=None, password=None, **kwargs):
|
||||||
print("authenticate")
|
print("authenticate")
|
||||||
# Get the user information from the LDAP if he can be authenticated
|
# Get the user information from the LDAP if he can be authenticated
|
||||||
isAdmin = False
|
isAdmin = False
|
||||||
isStaff = False
|
isStaff = False
|
||||||
|
|
||||||
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_ADMINS) is None:
|
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_ADMINS) is None:
|
||||||
print("authenticate-not admin")
|
print("authenticate-not admin")
|
||||||
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_STAFF) is None:
|
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_STAFF) is None:
|
||||||
print("authenticate-not staff")
|
print("authenticate-not staff")
|
||||||
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_USERS) is None:
|
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_USERS) is None:
|
||||||
print("authenticate-not user")
|
print("authenticate-not user")
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
print("authenticate-user")
|
print("authenticate-user")
|
||||||
|
|
@ -80,9 +80,9 @@ class LdapAuthenticationBackend(ModelBackend):
|
||||||
return user
|
return user
|
||||||
|
|
||||||
def get_user(self, user_id):
|
def get_user(self, user_id):
|
||||||
print("get_user")
|
print("get_user")
|
||||||
try:
|
try:
|
||||||
return User.objects.get(pk=user_id)
|
return User.objects.get(pk=user_id)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
print("get_user-user not found")
|
print("get_user-user not found")
|
||||||
return None
|
return None
|
||||||
|
|
@ -95,7 +95,7 @@ DATABASES = {
|
||||||
|
|
||||||
AUTHENTICATION_BACKENDS = [
|
AUTHENTICATION_BACKENDS = [
|
||||||
"django.contrib.auth.backends.ModelBackend",
|
"django.contrib.auth.backends.ModelBackend",
|
||||||
"ldapbackend.LdapAuthenticationBackend"
|
"webvirtcloud.ldapbackend.LdapAuthenticationBackend"
|
||||||
]
|
]
|
||||||
|
|
||||||
LOGIN_URL = "/accounts/login/"
|
LOGIN_URL = "/accounts/login/"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue