mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
Merge pull request #3598 from modoboa/django-auth-ldap-5
Compat with django-auth-ldap > 5
This commit is contained in:
@@ -7,6 +7,15 @@ services:
|
||||
volumes:
|
||||
- ./docker/redis:/data
|
||||
|
||||
ldap:
|
||||
image: docker.pkg.github.com/modoboa/docker-openldap/docker-openldap
|
||||
ports:
|
||||
- 389/tcp
|
||||
environment:
|
||||
LDAP_DOMAIN: example.com
|
||||
LDAP_ADMIN_PASSWORD: test
|
||||
profiles: [ldap]
|
||||
|
||||
rq:
|
||||
build:
|
||||
context: .
|
||||
|
||||
@@ -11,21 +11,23 @@ RUN apk add --update openssl librrd python3-dev libffi-dev \
|
||||
gcc g++ musl-dev libxml2-dev libxslt-dev \
|
||||
libressl-dev jpeg-dev rrdtool-dev file make \
|
||||
gettext freetype-dev cairo-dev cargo git \
|
||||
openldap-dev \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
RUN python3 -m venv $VIRTUAL_ENV
|
||||
WORKDIR /tmp
|
||||
COPY . /tmp
|
||||
RUN python -m pip install -U pip pip-tools ruff
|
||||
RUN pip-compile --output-file=requirements.txt pyproject.toml
|
||||
RUN pip-compile --extra=ldap --output-file=ldap-requirements.txt pyproject.toml
|
||||
RUN pip-compile --extra=dev --output-file=dev-requirements.txt pyproject.toml
|
||||
RUN pip-compile --extra=test --output-file=test-requirements.txt pyproject.toml
|
||||
RUN pip install -r requirements.txt -r test-requirements.txt -r dev-requirements.txt
|
||||
RUN pip install -r requirements.txt -r ldap-requirements.txt -r test-requirements.txt -r dev-requirements.txt
|
||||
|
||||
FROM base AS run
|
||||
COPY docker/doveadm /usr/local/bin
|
||||
RUN chmod +x /usr/local/bin/doveadm
|
||||
COPY --from=build $VIRTUAL_ENV $VIRTUAL_ENV
|
||||
RUN apk add --no-cache --update openssl librrd libxslt libjpeg libressl git rrdtool libmagic sudo sqlite \
|
||||
RUN apk add --no-cache --update openssl librrd libxslt libjpeg libressl git rrdtool libmagic sudo sqlite libldap \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
RUN mkdir /code
|
||||
WORKDIR /code
|
||||
|
||||
@@ -100,6 +100,12 @@ class LDAPAuthenticationTestCase(LDAPTestCaseMixin, ModoTestCase):
|
||||
def test_searchbind_authentication(self):
|
||||
"""Test the bind&search method."""
|
||||
self.searchbind_mode()
|
||||
self.set_global_parameters(
|
||||
{
|
||||
"ldap_admin_groups": "",
|
||||
"ldap_groups_search_base": "",
|
||||
}
|
||||
)
|
||||
username = "testuser@example.com"
|
||||
self.authenticate(username, "test")
|
||||
self.check_created_user(username)
|
||||
|
||||
@@ -77,11 +77,12 @@ try:
|
||||
ldap_user.attrs contains all of their LDAP attributes.
|
||||
"""
|
||||
group = "SimpleUsers"
|
||||
admin_groups = self.global_params["ldap_admin_groups"].split(";")
|
||||
for grp in admin_groups:
|
||||
if grp.strip() in ldap_user.group_names:
|
||||
group = "DomainAdmins"
|
||||
break
|
||||
admin_groups = self.global_params["ldap_admin_groups"]
|
||||
if admin_groups:
|
||||
for grp in admin_groups.split(";"):
|
||||
if grp.strip() in ldap_user.group_names:
|
||||
group = "DomainAdmins"
|
||||
break
|
||||
lpart, domain = split_mailbox(username)
|
||||
if domain is None:
|
||||
# Try to find associated email
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ test = [
|
||||
"testfixtures==8.3.0",
|
||||
"tox",
|
||||
]
|
||||
ldap = ["django-auth-ldap<5.0.0"]
|
||||
ldap = ["django-auth-ldap<6.0.0"]
|
||||
|
||||
[project.scripts]
|
||||
modoboa-cli = "modoboa:modoboa_admin"
|
||||
|
||||
Reference in New Issue
Block a user