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
7 changes: 6 additions & 1 deletion modoboa_radicale/backends/caldav_.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ 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 = smart_str(
param_tools.get_global_parameter("ssl_verify_cert"))
if ssl_verify_cert == "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
26 changes: 26 additions & 0 deletions modoboa_radicale/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
from modoboa.lib import form_utils
from modoboa.parameters import forms as param_forms

SSL_VERIFY_CHOICES = (
(True, ugettext_lazy("Verify")),
(False, ugettext_lazy("Skip verification")),
("path", ugettext_lazy("Provide CA bundle"))
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad indentation and I don't think it's a good idea to mix types here. Use either strings or integers for values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like that ?
I don't see the bad indent though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's better.
And the last parenthesis should be moved to start of line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :D



class ParametersForm(param_forms.AdminParametersForm):
"""Global parameters."""
Expand Down Expand Up @@ -56,3 +62,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=True,
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": "ssl_verify_cert=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