Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Castellum
castellum
Commits
ca8c4bf5
Commit
ca8c4bf5
authored
Apr 25, 2018
by
Bengfort
Browse files
activate ldap config only for stage
parent
5be360e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
castellum_core/castellum_core/castellum_core/settings/default.py
View file @
ca8c4bf5
...
...
@@ -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
=
'/'
...
...
castellum_core/castellum_core/castellum_core/settings/ldap.py
deleted
100644 → 0
View file @
5be360e5
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)'
)
castellum_core/castellum_core/castellum_core/settings/stage.py
View file @
ca8c4bf5
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)'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment