LDAP Authentication - Webmail / Dovecot (#1876)

* Adding settings options for dovecot ldap sync

* Creating update_dovecot_conf command

* Adding async command to update dovecot ldap conf

* Adding unit tests

* Adding port to dovecot generated uris & unit tests

* Code improvement & doc update & tests update
This commit is contained in:
Clément Rivière
2020-05-05 21:36:29 +02:00
committed by GitHub
parent 87931c4ab7
commit 8fa842d92c
10 changed files with 239 additions and 2 deletions
+22 -1
View File
@@ -18,7 +18,6 @@ from modoboa.parameters import forms as param_forms, tools as param_tools
from . import constants
from . import sms_backends
def enabled_applications():
"""Return the list of installed extensions."""
from modoboa.core.extensions import exts_pool
@@ -369,6 +368,23 @@ class GeneralParametersForm(param_forms.AdminParametersForm):
),
)
ldap_dovecot_sync = YesNoField(
label=ugettext_lazy("Enable Dovecot LDAP sync"),
initial=False,
help_text=ugettext_lazy(
"Enable synchronisation of Dovecot LDAP parameters from Modoboa."
)
)
ldap_dovecot_conf_file = forms.CharField(
label=ugettext_lazy("Dovecot LDAP config file"),
initial="/etc/dovecot/dovecot-modoboa.conf",
required=False,
help_text=ugettext_lazy(
"Dovecot LDAP configuration file location"
)
)
dash_sep = SeparatorField(label=ugettext_lazy("Dashboard"))
rss_feed_url = forms.URLField(
@@ -495,6 +511,7 @@ class GeneralParametersForm(param_forms.AdminParametersForm):
"ldap_import_search_base": "ldap_enable_import=True",
"ldap_import_search_filter": "ldap_enable_import=True",
"ldap_import_username_attr": "ldap_enable_import=True",
"ldap_dovecot_conf_file": "ldap_dovecot_sync=True",
"check_new_versions": "enable_api_communication=True",
"send_statistics": "enable_api_communication=True",
"send_new_versions_email": "check_new_versions=True",
@@ -682,3 +699,7 @@ class GeneralParametersForm(param_forms.AdminParametersForm):
from modoboa.lib.authbackends import LDAPSecondaryBackend
self._apply_ldap_settings(values, LDAPSecondaryBackend)
def to_dovecot_settings(self):
self.localconfig.need_dovecot_update = True
self.localconfig.save()
@@ -0,0 +1,18 @@
# Generated by Django 2.2.10 on 2020-04-29 12:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0020_auto_20200421_0851'),
]
operations = [
migrations.AddField(
model_name='localconfig',
name='need_dovecot_update',
field=models.BooleanField(default=False),
),
]
+3
View File
@@ -446,6 +446,9 @@ class LocalConfig(models.Model):
_parameters = jsonfield.JSONField(default={})
# Dovecot LDAP update
need_dovecot_update = models.BooleanField(default=False)
def __init__(self, *args, **kwargs):
"""Load parameter manager."""
super(LocalConfig, self).__init__(*args, **kwargs)
+2 -1
View File
@@ -88,7 +88,8 @@ SETTINGS_SAMPLE = {
"core-sms_password_recovery": False,
"core-sms_provider": "",
"core-sms_ovh_endpoint": "ovh-eu",
"core-password_recovery_msg": ""
"core-password_recovery_msg": "",
"core-ldap_dovecot_sync": False
}
+1
View File
@@ -35,6 +35,7 @@ def parameters(request, tplname="core/parameters.html"):
if form.is_valid():
form.save()
form.to_django_settings()
form.to_dovecot_settings()
continue
return render_to_json_response(
{"form_errors": form.errors, "prefix": form.app}, status=400