diff --git a/.github/workflows/plugin.yml b/.github/workflows/plugin.yml index 4fc4cd8..e97b7b7 100644 --- a/.github/workflows/plugin.yml +++ b/.github/workflows/plugin.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest services: postgres: - image: postgres:11 + image: postgres:12 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres @@ -41,20 +41,24 @@ jobs: strategy: matrix: database: ['postgres', 'mysql'] - python-version: [3.7, 3.8, 3.9] + python-version: [3.8, 3.9, '3.10'] fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - sudo apt-get update -y && sudo apt-get install -y librrd-dev rrdtool + sudo apt-get update -y \ + && sudo apt-get update -y && sudo apt-get install -y librrd-dev rrdtool python -m pip install --upgrade pip - pip install -e git+https://github.com/modoboa/modoboa.git#egg=modoboa + git clone https://github.com/modoboa/modoboa.git + cd modoboa + python setup.py develop + cd .. pip install -r requirements.txt pip install -r test-requirements.txt python setup.py develop diff --git a/modoboa_radicale/backends/caldav_.py b/modoboa_radicale/backends/caldav_.py index c79ea9a..2fbc5af 100644 --- a/modoboa_radicale/backends/caldav_.py +++ b/modoboa_radicale/backends/caldav_.py @@ -14,6 +14,7 @@ from modoboa.parameters import tools as param_tools from . import CalendarBackend +from .. import constants class Caldav_Backend(CalendarBackend): @@ -24,9 +25,17 @@ def __init__(self, username, password, calendar=None): super(Caldav_Backend, self).__init__(calendar) server_url = smart_str( param_tools.get_global_parameter("server_location")) + ssl_verify_cert = param_tools.get_global_parameter("ssl_verify_cert") + if ssl_verify_cert == constants.VERIFY: + ssl_verify_cert = True + elif ssl_verify_cert == constants.NO_VERIFY: + ssl_verify_cert = False + elif ssl_verify_cert == constants.PATH: + ssl_verify_cert = param_tools.get_global_parameter("ssl_ca_bundle_path") self.client = caldav.DAVClient( server_url, - username=username, password=password) + username=username, password=password, + ssl_verify_cert=ssl_verify_cert) if self.calendar: self.remote_cal = Calendar(self.client, calendar.encoded_path) diff --git a/modoboa_radicale/constants.py b/modoboa_radicale/constants.py new file mode 100644 index 0000000..ca67365 --- /dev/null +++ b/modoboa_radicale/constants.py @@ -0,0 +1,5 @@ +"""Constants for modoboa-radicale""" + +VERIFY = 1 +NO_VERIFY = 2 +PATH = 3 diff --git a/modoboa_radicale/forms.py b/modoboa_radicale/forms.py index ce11b2b..0add122 100644 --- a/modoboa_radicale/forms.py +++ b/modoboa_radicale/forms.py @@ -6,6 +6,14 @@ from modoboa.lib import form_utils from modoboa.parameters import forms as param_forms +from . import constants + +SSL_VERIFY_CHOICES = ( + (constants.VERIFY, ugettext_lazy("Verify")), + (constants.NO_VERIFY, ugettext_lazy("Skip verification")), + (constants.PATH, ugettext_lazy("Provide CA bundle")) +) + class ParametersForm(param_forms.AdminParametersForm): """Global parameters.""" @@ -56,3 +64,23 @@ class ParametersForm(param_forms.AdminParametersForm): "Maximum size in bytes of imported ICS files " "(or KB, MB, GB if specified)") ) + + ssl_verify_cert = forms.ChoiceField( + choices=SSL_VERIFY_CHOICES, + initial=constants.VERIFY, + label=ugettext_lazy("Type of ssl verification"), + help_text=ugettext_lazy("It might be needed to set to custom " + "and set a CA bundle or set to 'Skip verification' " + "in case of a self-signed cert") + ) + + ssl_ca_bundle_path = forms.CharField( + label=ugettext_lazy("Path to CA bundle"), + initial="", + help_text=ugettext_lazy( + "Path to the CA bundle. ") + ) + + visibility_rules = { + "ssl_ca_bundle_path": f"ssl_verify_cert={constants.PATH}" + } diff --git a/test_project/test_project/settings.py b/test_project/test_project/settings.py index 7dc52a3..edb2f86 100644 --- a/test_project/test_project/settings.py +++ b/test_project/test_project/settings.py @@ -78,6 +78,9 @@ 'modoboa.dnstools', 'modoboa.policyd', 'modoboa.maillog', + 'modoboa.dmarc', + 'modoboa.pdfcredentials', + 'modoboa.imap_migration', # Modoboa extensions here. 'modoboa_radicale', )