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
2a310f07
Verified
Commit
2a310f07
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Enable use of LDAP groupd to set account flags
parent
189aa83e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!149
Support global permission flags by LDAP group
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/settings.py
+23
-1
23 additions, 1 deletion
aleksis/core/settings.py
with
23 additions
and
1 deletion
aleksis/core/settings.py
+
23
−
1
View file @
2a310f07
...
...
@@ -186,7 +186,7 @@ AUTHENTICATION_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
from
django_auth_ldap.config
import
LDAPSearch
,
GroupOfNamesType
,
GroupOfUniqueNamesType
,
PosixGroupType
# noqa
# Enable Django's integration to LDAP
AUTHENTICATION_BACKENDS
.
append
(
"
django_auth_ldap.backend.LDAPBackend
"
)
...
...
@@ -212,6 +212,28 @@ if _settings.get("ldap.uri", None):
"
email
"
:
_settings
.
get
(
"
ldap.map.email
"
,
"
mail
"
),
}
# Discover flags by LDAP groups
if
_settings
.
get
(
"
ldap.groups.base
"
,
None
):
AUTH_LDAP_GROUP_SEARCH
=
LDAPSearch
(
_settings
.
get
(
"
ldap.groups.base
"
),
ldap
.
SCOPE_SUBTREE
,
_settings
.
get
(
"
ldap.groups.filter
"
,
"
(objectClass=%s)
"
%
_settings
.
get
(
"
ldap.groups.type
"
,
"
groupOfNams
"
)),
)
if
_settings
.
get
(
"
ldap.groups.type
"
,
"
groupOfNames
"
):
AUTH_LDAP_GROUP_TYPE
=
NestedGroupOfNamesType
()
elif
_settings
.
get
(
"
ldap.groups.type
"
,
"
groupOfUniqueNames
"
):
AUTH_LDAP_GROUP_TYPE
=
NestedGroupOfUniqueNamesType
()
elif
_settings
.
get
(
"
ldap.groups.type
"
,
"
posixGroup
"
):
AUTH_LDAP_GROUP_TYPE
=
PosixGroupType
()
AUTH_LDAP_USER_FLAGS_BY_GROUP
=
{
}
for
flag
in
[
"
is_active
"
,
"
is_staff
"
,
"
is_superuser
"
]:
dn
=
_settings
.
get
(
"
ldap.groups.flags.%s
"
%
flag
,
None
)
if
dn
:
AUTH_LDAP_USER_FLAGS_BY_GROUP
[
flag
]
=
dn
# Add ModelBckend last so all other backends get a chance
# to verify passwords first
AUTHENTICATION_BACKENDS
.
append
(
"
django.contrib.auth.backends.ModelBackend
"
)
...
...
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