Pickup env variables and use them
This commit is contained in:
parent
a3dca06c35
commit
113fa2c454
2 changed files with 18 additions and 5 deletions
|
@ -16,9 +16,16 @@ import ldap
|
||||||
from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion
|
from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion
|
||||||
|
|
||||||
# LDAP setup
|
# LDAP setup
|
||||||
|
LDAP_SERVER = config('LDAP_SERVER')
|
||||||
AUTH_LDAP_SERVER_URI = config('LDAPSERVER')
|
AUTH_LDAP_SERVER_URI = config('LDAPSERVER')
|
||||||
AUTH_LDAP_BIND_DN = config('LDAPSEARCHUSER')
|
|
||||||
AUTH_LDAP_BIND_PASSWORD = config('LDAPSEARCHUSERPASSWORD')
|
LDAP_ADMIN_DN = config('LDAP_ADMIN_DN')
|
||||||
|
LDAP_ADMIN_PASSWORD = config('LDAP_ADMIN_PASSWORD')
|
||||||
|
AUTH_LDAP_BIND_DN = LDAP_ADMIN_DN
|
||||||
|
AUTH_LDAP_BIND_PASSWORD = LDAP_ADMIN_PASSWORD
|
||||||
|
|
||||||
|
LDAP_CUSTOMER_DN = config('LDAP_CUSTOMER_DN')
|
||||||
|
LDAP_USERS_DN = config('LDAP_USERS_DN')
|
||||||
|
|
||||||
# Search union over OUs
|
# Search union over OUs
|
||||||
search_base = config('LDAPSEARCH').split()
|
search_base = config('LDAPSEARCH').split()
|
||||||
|
@ -177,3 +184,9 @@ if config('ENABLE_DEBUG_LOG', default=False, cast=bool):
|
||||||
loggers_dict.update(logger_item)
|
loggers_dict.update(logger_item)
|
||||||
|
|
||||||
LOGGING['loggers'] = loggers_dict
|
LOGGING['loggers'] = loggers_dict
|
||||||
|
|
||||||
|
if 'ldap3' in modules_to_log_list:
|
||||||
|
from ldap3.utils.log import (
|
||||||
|
set_library_log_detail_level, OFF, BASIC, NETWORK, EXTENDED
|
||||||
|
)
|
||||||
|
set_library_log_detail_level(BASIC)
|
||||||
|
|
|
@ -32,8 +32,8 @@ from django.conf import settings
|
||||||
class LDAP(object):
|
class LDAP(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.uri = settings.AUTH_LDAP_SERVER_URI
|
self.uri = settings.AUTH_LDAP_SERVER_URI
|
||||||
self.user = settings.AUTH_LDAP_BIND_DN
|
self.user = settings.LDAP_ADMIN_DN
|
||||||
self.password = settings.AUTH_LDAP_BIND_PASSWORD
|
self.password = settings.LDAP_ADMIN_PASSWORD
|
||||||
|
|
||||||
# FIXME: take from settings
|
# FIXME: take from settings
|
||||||
self.search_base = os.environ['LDAPSEARCH']
|
self.search_base = os.environ['LDAPSEARCH']
|
||||||
|
@ -41,7 +41,7 @@ class LDAP(object):
|
||||||
self.search_filter = "objectClass=inetOrgPerson"
|
self.search_filter = "objectClass=inetOrgPerson"
|
||||||
|
|
||||||
# FIXME: hard coded
|
# FIXME: hard coded
|
||||||
self.dn = "uid={{}},{}".format(os.environ['LDAPCREATE'])
|
self.dn = "uid={{}},{}".format(settings.LDAP_CUSTOMER_DN)
|
||||||
self.gid = "10004"
|
self.gid = "10004"
|
||||||
|
|
||||||
self.conn = ldap.initialize(self.uri)
|
self.conn = ldap.initialize(self.uri)
|
||||||
|
|
Loading…
Reference in a new issue