Merge branch 'mryauch-master'
This commit is contained in:
commit
54ac5dc2ab
@ -1,7 +1,8 @@
|
|||||||
import ldap
|
import ldap
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
|
from django_auth_ldap.config import LDAPSearch
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
# Read secret from file
|
# Read secret from file
|
||||||
def read_secret(secret_name):
|
def read_secret(secret_name):
|
||||||
@ -13,6 +14,14 @@ def read_secret(secret_name):
|
|||||||
with f:
|
with f:
|
||||||
return f.readline().strip()
|
return f.readline().strip()
|
||||||
|
|
||||||
|
# Import and return the group type based on string name
|
||||||
|
def import_group_type(group_type_name):
|
||||||
|
mod = import_module('django_auth_ldap.config')
|
||||||
|
try:
|
||||||
|
return getattr(mod, group_type_name)()
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
# Server URI
|
# Server URI
|
||||||
AUTH_LDAP_SERVER_URI = os.environ.get('AUTH_LDAP_SERVER_URI', '')
|
AUTH_LDAP_SERVER_URI = os.environ.get('AUTH_LDAP_SERVER_URI', '')
|
||||||
|
|
||||||
@ -45,7 +54,7 @@ AUTH_LDAP_GROUP_SEARCH_BASEDN = os.environ.get('AUTH_LDAP_GROUP_SEARCH_BASEDN',
|
|||||||
AUTH_LDAP_GROUP_SEARCH_CLASS = os.environ.get('AUTH_LDAP_GROUP_SEARCH_CLASS', 'group')
|
AUTH_LDAP_GROUP_SEARCH_CLASS = os.environ.get('AUTH_LDAP_GROUP_SEARCH_CLASS', 'group')
|
||||||
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(AUTH_LDAP_GROUP_SEARCH_BASEDN, ldap.SCOPE_SUBTREE,
|
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(AUTH_LDAP_GROUP_SEARCH_BASEDN, ldap.SCOPE_SUBTREE,
|
||||||
"(objectClass=" + AUTH_LDAP_GROUP_SEARCH_CLASS + ")")
|
"(objectClass=" + AUTH_LDAP_GROUP_SEARCH_CLASS + ")")
|
||||||
AUTH_LDAP_GROUP_TYPE = GroupOfNamesType()
|
AUTH_LDAP_GROUP_TYPE = import_group_type(os.environ.get('AUTH_LDAP_GROUP_TYPE', 'GroupOfNamesType'))
|
||||||
|
|
||||||
# Define a group required to login.
|
# Define a group required to login.
|
||||||
AUTH_LDAP_REQUIRE_GROUP = os.environ.get('AUTH_LDAP_REQUIRE_GROUP_DN', '')
|
AUTH_LDAP_REQUIRE_GROUP = os.environ.get('AUTH_LDAP_REQUIRE_GROUP_DN', '')
|
||||||
|
Loading…
Reference in New Issue
Block a user