mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-29 11:44:28 +01:00
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:
@@ -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),
|
||||
),
|
||||
]
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user