Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
02ff55f6
Commit
02ff55f6
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Configure django-auth-ldap from config file. Advances
#23
.
parent
c7a81909
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biscuit/core/settings.py
+35
-0
35 additions, 0 deletions
biscuit/core/settings.py
with
35 additions
and
0 deletions
biscuit/core/settings.py
+
35
−
0
View file @
02ff55f6
...
...
@@ -132,6 +132,41 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Authentication backends are dynamically populated
AUTEHNTICATION_BACKENDS
=
[]
if
_settings
.
get
(
'
ldap.uri
'
,
None
):
# LDAP dependencies are not necessarily installed, so import them here
import
ldap
# noqa
from
django_auth_ldap.config
import
LDAPSearch
,
GroupOfNamesType
# noqa
# Enable Django's integration to LDAP
AUTHENTICATION_BACKENDS
.
append
(
'
django_auth_ldap.backend.LDAPBackend
'
)
AUTH_LDAP_SERVER_URI
=
_settings
.
get
(
'
ldap.uri
'
)
# Optional: non-anonymous bind
if
_settings
.
get
(
'
ldap.bind.dn
'
,
None
):
AUTH_LDAP_BIND_DN
=
_settings
.
get
(
'
ldap.bind.dn
'
)
AUTH_LDAP_BIND_PASSWORD
=
_settings
.
get
(
'
ldap.bind.password
'
)
# Search attributes to find users by username
AUTH_LDAP_USER_SEARCH
=
LDAPSearch
(
_settings
.
get
(
'
ldap.users.base
'
),
ldap
.
SCOPE_SUBTREE
,
_settings
.
get
(
'
ldap.users.filter
'
)
)
# Mapping of LDAP attributes to Django model fields
AUTH_LDAP_USER_ATTR_MAP
=
{
'
first_name
'
:
_settings
.
get
(
'
ldap.map.first_name
'
,
'
givenName
'
),
'
last_name
'
:
_settings
.
get
(
'
ldap.map.first_name
'
,
'
sn
'
),
'
email
'
:
_settings
.
get
(
'
ldap.map.email
'
,
'
mail
'
),
}
# Add ModelBckend last so all other backends get a chance
# to verify passwords first
AUTHENTICATION_BACKENDS
.
append
(
'
django.contrib.auth.backends.ModelBackend
'
)
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment