mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Added checks for Dovecot and Radicale oauth2 app
This commit is contained in:
+45
-3
@@ -1,8 +1,10 @@
|
||||
from django.db.utils import ProgrammingError, OperationalError
|
||||
from django.core.checks import register, Info, Warning
|
||||
from django.core.checks import register, Info, Warning, Error
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from oauth2_provider.models import get_application_model
|
||||
|
||||
from modoboa.core.utils import (
|
||||
check_for_deprecated_password_schemes,
|
||||
generate_rsa_private_key,
|
||||
@@ -15,14 +17,38 @@ W001 = Warning(
|
||||
"twice due to clock change)."
|
||||
),
|
||||
hint=_("Set `USE_TZ = True` in settings.py"),
|
||||
id="modoboa.W001",
|
||||
id="modoboa.core.W001",
|
||||
)
|
||||
W002 = Warning(
|
||||
_("The password scheme you are using is deprecated."),
|
||||
hint=_("Upgrade your password scheme to a stronger one"),
|
||||
id="modoboa.W002",
|
||||
id="modoboa.core.W002",
|
||||
)
|
||||
|
||||
E001 = Error(
|
||||
_(
|
||||
"Oauth2 application for dovecot has not been found."
|
||||
" Webmail and some other features won't be available."
|
||||
),
|
||||
hint=_(
|
||||
"Visit : https://modoboa.readthedocs.io/en/latest/manual_installation/dovecot.html#dovecot-oauth2"
|
||||
),
|
||||
id="modoboa.core.E001",
|
||||
)
|
||||
|
||||
E002 = Error(
|
||||
_(
|
||||
"Oauth2 application for radicale has not been found."
|
||||
" Calendar and some other features won't be available."
|
||||
),
|
||||
id="modoboa.core.E002",
|
||||
)
|
||||
|
||||
|
||||
def oauth_app_exists(app_name):
|
||||
oauth_application = get_application_model().objects.filter(name=app_name)
|
||||
return oauth_application.exists()
|
||||
|
||||
|
||||
@register(deploy=True)
|
||||
def check_use_tz_enabled(app_configs, **kwargs):
|
||||
@@ -59,3 +85,19 @@ def check_password_hasher(app_configs, **kwargs):
|
||||
if hasher:
|
||||
msgs.append(W002)
|
||||
return msgs
|
||||
|
||||
|
||||
@register(deploy=True)
|
||||
def check_dovecot_oauth_app(*args, **kwargs):
|
||||
error = []
|
||||
if not oauth_app_exists("Dovecot"):
|
||||
error.append(E001)
|
||||
return error
|
||||
|
||||
|
||||
@register(deploy=True)
|
||||
def check_radicale_oauth_app(*args, **kwargs):
|
||||
error = []
|
||||
if not oauth_app_exists("Radicale"):
|
||||
error.append(E002)
|
||||
return error
|
||||
|
||||
Reference in New Issue
Block a user