From 82d9d5ff0811fa3100a3866adab7a7e6837f70ea Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Thu, 1 Aug 2024 12:44:11 +0200 Subject: [PATCH] Make sure to catch all DNS exceptions. --- doc/manual_installation/dovecot.rst | 10 +++++----- doc/upgrade.rst | 6 ++++++ modoboa/admin/lib.py | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/doc/manual_installation/dovecot.rst b/doc/manual_installation/dovecot.rst index 29fe177a4..09384d48c 100644 --- a/doc/manual_installation/dovecot.rst +++ b/doc/manual_installation/dovecot.rst @@ -254,6 +254,8 @@ For debian and derivative, you need to install sqlite connector for dovecot:: Replace values between ``<>`` with yours. +.. _dovecot_oauth2: + OAuth 2 authentication ====================== @@ -264,9 +266,7 @@ application with the following commands: .. sourcecode:: bash > cd - > python manage.py createapplication --name=Dovecot --algorithm=RS256 --skip-authorization --redirect-uris=http://localhost --client-secret= public authorization-code - -Choose a value for ```` (you can generate a random one). + > python manage.py createapplication --name=Dovecot --skip-authorization --client-id=dovecot confidential client-credentials On success, you should see an output similar to:: @@ -291,13 +291,13 @@ Finally, create a file named :file:`conf.d/dovecot-oauth2.conf.ext` with the following content:: introspection_mode = post - introspection_url = http://:@localhost/api/o/introspect/ + introspection_url = http://dovecot:@localhost/api/o/introspect/ username_attribute = username tls_ca_cert_file = /etc/ssl/certs/ca-certificates.crt active_attribute = active active_value = true -Replace ```` and ```` with the values you obtained earlier. +Replace ```` with the value you obtained earlier. LDAP ==== diff --git a/doc/upgrade.rst b/doc/upgrade.rst index 82ff4c639..87f02a173 100644 --- a/doc/upgrade.rst +++ b/doc/upgrade.rst @@ -331,6 +331,12 @@ by default. # If CORS fail, you might want to try to set it to True #CORS_ORIGIN_ALLOW_ALL = False +Docevot configuration changes +----------------------------- + +You must enable oauth2 authentication in Dovecot to make the filters +editor work in the new UI. Follow this :ref:`guide `. + Post update ----------- diff --git a/modoboa/admin/lib.py b/modoboa/admin/lib.py index 256ad23e0..bfbb07a8e 100644 --- a/modoboa/admin/lib.py +++ b/modoboa/admin/lib.py @@ -192,13 +192,13 @@ def get_dns_resolver(): def get_authoritative_server(domain, resolver=None): if not resolver: - resolver = get_dns_resolver() + resolver = get_dns_resolver() dnsname = dns.name.from_text(domain) while True: try: - answers = dns.resolver.resolve(dnsname, 'NS') + answers = dns.resolver.resolve(dnsname, "NS") if answers: first_answer = answers[0] if hasattr(first_answer, "target"): @@ -214,7 +214,7 @@ def get_authoritative_server(domain, resolver=None): def get_authoritative_ip(domain, resolver=None): dnsserver_name = get_authoritative_server(domain, resolver=resolver) if not resolver: - resolver = get_dns_resolver() + resolver = get_dns_resolver() answer = resolver.resolve(dnsserver_name) if answer: return answer[0].address @@ -235,8 +235,8 @@ def get_dns_records(name, typ, resolver=None): """Retrieve DNS records for given name and type.""" logger = logging.getLogger("modoboa.admin") - resolver = get_authoritative_resolver(name, resolver=resolver) try: + resolver = get_authoritative_resolver(name, resolver=resolver) dns_answers = resolver.resolve(name, typ, search=True) except dns.resolver.NXDOMAIN as e: logger.error(_("No DNS record found for %s") % name, exc_info=e)