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
df039094
Verified
Commit
df039094
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into feature/extensible-model-fk
parents
5514e0ab
edc5c39d
No related branches found
No related tags found
1 merge request
!305
Allow adding a foreign key to Exensible Model
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
aleksis/core/settings.py
+30
-12
30 additions, 12 deletions
aleksis/core/settings.py
docs/admin/02_ldap.rst
+3
-1
3 additions, 1 deletion
docs/admin/02_ldap.rst
poetry.lock
+83
-85
83 additions, 85 deletions
poetry.lock
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
with
117 additions
and
99 deletions
aleksis/core/settings.py
+
30
−
12
View file @
df039094
...
@@ -209,6 +209,7 @@ if _settings.get("ldap.uri", None):
...
@@ -209,6 +209,7 @@ if _settings.get("ldap.uri", None):
import
ldap
# noqa
import
ldap
# noqa
from
django_auth_ldap.config
import
(
from
django_auth_ldap.config
import
(
LDAPSearch
,
LDAPSearch
,
LDAPSearchUnion
,
NestedGroupOfNamesType
,
NestedGroupOfNamesType
,
NestedGroupOfUniqueNamesType
,
NestedGroupOfUniqueNamesType
,
PosixGroupType
,
PosixGroupType
,
...
@@ -224,27 +225,44 @@ if _settings.get("ldap.uri", None):
...
@@ -224,27 +225,44 @@ if _settings.get("ldap.uri", None):
AUTH_LDAP_BIND_DN
=
_settings
.
get
(
"
ldap.bind.dn
"
)
AUTH_LDAP_BIND_DN
=
_settings
.
get
(
"
ldap.bind.dn
"
)
AUTH_LDAP_BIND_PASSWORD
=
_settings
.
get
(
"
ldap.bind.password
"
)
AUTH_LDAP_BIND_PASSWORD
=
_settings
.
get
(
"
ldap.bind.password
"
)
# The TOML config might contain either one table or an array of tables
_AUTH_LDAP_USER_SETTINGS
=
_settings
.
get
(
"
ldap.users.search
"
)
if
not
isinstance
(
_AUTH_LDAP_USER_SETTINGS
,
list
):
_AUTH_LDAP_USER_SETTINGS
=
[
_AUTH_LDAP_USER_SETTINGS
]
# Search attributes to find users by username
# Search attributes to find users by username
AUTH_LDAP_USER_SEARCH
=
LDAPSearch
(
AUTH_LDAP_USER_SEARCH
=
LDAPSearchUnion
(
_settings
.
get
(
"
ldap.users.base
"
),
*
[
ldap
.
SCOPE_SUBTREE
,
LDAPSearch
(
entry
[
"
base
"
],
ldap
.
SCOPE_SUBTREE
,
entry
.
get
(
"
filter
"
,
"
(uid=%(user)s)
"
),)
_settings
.
get
(
"
ldap.users.filter
"
,
"
(uid=%(user)s)
"
),
for
entry
in
_AUTH_LDAP_USER_SETTINGS
]
)
)
# Mapping of LDAP attributes to Django model fields
# Mapping of LDAP attributes to Django model fields
AUTH_LDAP_USER_ATTR_MAP
=
{
AUTH_LDAP_USER_ATTR_MAP
=
{
"
first_name
"
:
_settings
.
get
(
"
ldap.map.first_name
"
,
"
givenName
"
),
"
first_name
"
:
_settings
.
get
(
"
ldap.
users.
map.first_name
"
,
"
givenName
"
),
"
last_name
"
:
_settings
.
get
(
"
ldap.map.last_name
"
,
"
sn
"
),
"
last_name
"
:
_settings
.
get
(
"
ldap.
users.
map.last_name
"
,
"
sn
"
),
"
email
"
:
_settings
.
get
(
"
ldap.map.email
"
,
"
mail
"
),
"
email
"
:
_settings
.
get
(
"
ldap.
users.
map.email
"
,
"
mail
"
),
}
}
# Discover flags by LDAP groups
# Discover flags by LDAP groups
if
_settings
.
get
(
"
ldap.groups.
ba
se
"
,
None
):
if
_settings
.
get
(
"
ldap.groups.se
arch
"
,
None
):
group_type
=
_settings
.
get
(
"
ldap.groups.type
"
,
"
groupOfNames
"
)
group_type
=
_settings
.
get
(
"
ldap.groups.type
"
,
"
groupOfNames
"
)
AUTH_LDAP_GROUP_SEARCH
=
LDAPSearch
(
_settings
.
get
(
"
ldap.groups.base
"
),
# The TOML config might contain either one table or an array of tables
ldap
.
SCOPE_SUBTREE
,
_AUTH_LDAP_GROUP_SETTINGS
=
_settings
.
get
(
"
ldap.groups.search
"
)
_settings
.
get
(
"
ldap.groups.filter
"
,
f
"
(objectClass=
{
group_type
}
)
"
),
if
not
isinstance
(
_AUTH_LDAP_GROUP_SETTINGS
,
list
):
_AUTH_LDAP_GROUP_SETTINGS
=
[
_AUTH_LDAP_GROUP_SETTINGS
]
AUTH_LDAP_GROUP_SEARCH
=
LDAPSearchUnion
(
*
[
LDAPSearch
(
entry
[
"
base
"
],
ldap
.
SCOPE_SUBTREE
,
entry
.
get
(
"
filter
"
,
f
"
(objectClass=
{
group_type
}
)
"
),
)
for
entry
in
_AUTH_LDAP_GROUP_SETTINGS
]
)
)
_group_type
=
_settings
.
get
(
"
ldap.groups.type
"
,
"
groupOfNames
"
).
lower
()
_group_type
=
_settings
.
get
(
"
ldap.groups.type
"
,
"
groupOfNames
"
).
lower
()
...
...
This diff is collapsed.
Click to expand it.
docs/admin/02_ldap.rst
+
3
−
1
View file @
df039094
...
@@ -28,5 +28,7 @@ existing file or add a new one)::
...
@@ -28,5 +28,7 @@ existing file or add a new one)::
[default.ldap]
[default.ldap]
uri = "ldaps://ldap.myschool.edu"
uri = "ldaps://ldap.myschool.edu"
bind = { dn = "cn=reader,dc=myschool,dc=edu", password = "secret" }
bind = { dn = "cn=reader,dc=myschool,dc=edu", password = "secret" }
users = { base = "ou=people,dc=myschool,dc=edu", filter = "(uid=%(user)s)" }
[default.ldap.users]
search = { base = "ou=people,dc=myschool,dc=edu", filter = "(uid=%(user)s)" }
map = { first_name = "givenName", last_name = "sn", email = "mail" }
map = { first_name = "givenName", last_name = "sn", email = "mail" }
This diff is collapsed.
Click to expand it.
poetry.lock
+
83
−
85
View file @
df039094
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
1
View file @
df039094
...
@@ -43,7 +43,7 @@ libsass = "^0.20.0"
...
@@ -43,7 +43,7 @@ libsass = "^0.20.0"
colour
=
"^0.1.5"
colour
=
"^0.1.5"
dynaconf
=
{
version
=
"^2.0"
,
extras
=
[
"yaml"
,
"toml"
,
"ini"
]}
dynaconf
=
{
version
=
"^2.0"
,
extras
=
[
"yaml"
,
"toml"
,
"ini"
]}
django-settings-context-processor
=
"^0.2"
django-settings-context-processor
=
"^0.2"
django-auth-ldap
=
{
version
=
"^2.
0
"
,
optional
=
true
}
django-auth-ldap
=
{
version
=
"^2.
2
"
,
optional
=
true
}
django-maintenance-mode
=
"^0.14.0"
django-maintenance-mode
=
"^0.14.0"
django-ipware
=
"^2.1"
django-ipware
=
"^2.1"
easy-thumbnails
=
"^2.6"
easy-thumbnails
=
"^2.6"
...
...
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