Implement authentication with LDAP

Enable an additional lookup against an LDAP directory
during login and user creation to ensure that only
specific users can login and register on the EteBase
server instance.
This commit is contained in:
2020-11-06 15:22:26 +01:00
parent 801826b8b6
commit 1fef1e2b7a
5 changed files with 98 additions and 1 deletions

View File

@@ -164,6 +164,17 @@ if any(os.path.isfile(x) for x in config_locations):
if 'database' in config:
DATABASES = { 'default': { x.upper(): y for x, y in config.items('database') } }
if 'ldap' in config:
ldap = config['ldap']
ETEBASE_USE_LDAP = True
ETEBASE_LDAP_SERVER = ldap.get('server', '')
ETEBASE_LDAP_SEARCH_BASE = ldap.get('search_base', '')
ETEBASE_LDAP_FILTER = ldap.get('filter', '')
ETEBASE_LDAP_BIND_DN = ldap.get('bind_dn', '')
ETEBASE_LDAP_BIND_PW = ldap.get('bind_pw', '')
else:
ETEBASE_USE_LDAP = False
ETEBASE_API_PERMISSIONS = ('rest_framework.permissions.IsAuthenticated', )
ETEBASE_API_AUTHENTICATORS = ('django_etebase.token_auth.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication')