Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added settings for caldav ssl verification #112

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
16 changes: 10 additions & 6 deletions .github/workflows/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion modoboa_radicale/backends/caldav_.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from modoboa.parameters import tools as param_tools

from . import CalendarBackend
from .. import constants


class Caldav_Backend(CalendarBackend):
Expand All @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions modoboa_radicale/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Constants for modoboa-radicale"""

VERIFY = 1
NO_VERIFY = 2
PATH = 3
28 changes: 28 additions & 0 deletions modoboa_radicale/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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}"
}
3 changes: 3 additions & 0 deletions test_project/test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
'modoboa.dnstools',
'modoboa.policyd',
'modoboa.maillog',
'modoboa.dmarc',
'modoboa.pdfcredentials',
'modoboa.imap_migration',
# Modoboa extensions here.
'modoboa_radicale',
)
Expand Down