Commit ca8c4bf5 authored by Bengfort's avatar Bengfort
Browse files

activate ldap config only for stage

parent 5be360e5
......@@ -75,20 +75,6 @@ AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
LDAP_ENABLED = True
if LDAP_ENABLED:
try:
from .ldap import *
except ImportError:
raise ImportError(
"Failed to load LDAP settings. Either you disable LDAP by setting "
"'LDAP_ENABLED = False' or you create a ldap.py file in the settings directory!"
)
AUTHENTICATION_BACKENDS.append("django_auth_ldap.backend.LDAPBackend")
AUTH_USER_MODEL = 'castellum_auth.User'
LOGIN_REDIRECT_URL = '/'
......
import ldap
import os
from django_auth_ldap.config import LDAPSearch
host = os.environ.get("LDAP_HOST", "ldap://localhost")
distinguised_name = os.environ.get("LDAP_DISTINGUISHED_NAME", "dc=example,dc=org")
username = os.environ.get("LDAP_USERNAME", "cn=admin," + distinguised_name)
password = os.environ.get("LDAP_PASSWORD", "admin")
AUTH_LDAP_SERVER_URI = host
AUTH_LDAP_BIND_DN = username
AUTH_LDAP_BIND_PASSWORD = password
AUTH_LDAP_USER_SEARCH = LDAPSearch(distinguised_name, ldap.SCOPE_SUBTREE, '(uid=%(user)s)')
import ldap
import os
from django_auth_ldap.config import LDAPSearch
from .default import *
......@@ -15,3 +19,15 @@ ALLOWED_HOSTS = [
'localhost',
]
# LDAP
AUTHENTICATION_BACKENDS.append("django_auth_ldap.backend.LDAPBackend")
host = os.environ.get("LDAP_HOST", "ldap://localhost")
distinguised_name = os.environ.get("LDAP_DISTINGUISHED_NAME", "dc=example,dc=org")
username = os.environ.get("LDAP_USERNAME", "cn=admin," + distinguised_name)
password = os.environ.get("LDAP_PASSWORD", "admin")
AUTH_LDAP_SERVER_URI = host
AUTH_LDAP_BIND_DN = username
AUTH_LDAP_BIND_PASSWORD = password
AUTH_LDAP_USER_SEARCH = LDAPSearch(distinguised_name, ldap.SCOPE_SUBTREE, '(uid=%(user)s)')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment