Compare commits
11 Commits
mailbox-au
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00d79f518d | ||
|
|
03b124501e | ||
|
|
5f357aef42 | ||
|
|
e1aa0ab723 | ||
|
|
88b2384fa8 | ||
|
|
bb02255c0f | ||
|
|
7a38a535f8 | ||
|
|
2121cfe267 | ||
|
|
36c8352223 | ||
|
|
01ec9b406f | ||
|
|
f2c7423296 |
@@ -1,5 +1,6 @@
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
import uuid
|
||||||
|
|
||||||
from .constants import DEFAULT_BACKUP_DIRECTORY
|
from .constants import DEFAULT_BACKUP_DIRECTORY
|
||||||
|
|
||||||
@@ -11,6 +12,10 @@ def make_password(length=16):
|
|||||||
string.ascii_letters + string.digits) for _ in range(length))
|
string.ascii_letters + string.digits) for _ in range(length))
|
||||||
|
|
||||||
|
|
||||||
|
def make_client_secret():
|
||||||
|
return str(uuid.uuid4())
|
||||||
|
|
||||||
|
|
||||||
# Validators should return a tuple bool, error message
|
# Validators should return a tuple bool, error message
|
||||||
def is_email(user_input):
|
def is_email(user_input):
|
||||||
"""Return True in input is a valid email"""
|
"""Return True in input is a valid email"""
|
||||||
@@ -351,6 +356,10 @@ ConfigDictTemplate = [
|
|||||||
"option": "move_spam_to_junk",
|
"option": "move_spam_to_junk",
|
||||||
"default": "true",
|
"default": "true",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"option": "oauth2_client_secret",
|
||||||
|
"default": make_client_secret
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -480,7 +489,11 @@ ConfigDictTemplate = [
|
|||||||
{
|
{
|
||||||
"option": "venv_path",
|
"option": "venv_path",
|
||||||
"default": "%(home_dir)s/env",
|
"default": "%(home_dir)s/env",
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"option": "oauth2_client_secret",
|
||||||
|
"default": make_client_secret
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -154,7 +154,10 @@ class Dovecot(base.Installer):
|
|||||||
protocols = ""
|
protocols = ""
|
||||||
|
|
||||||
oauth2_client_id, oauth2_client_secret = utils.create_oauth2_app(
|
oauth2_client_id, oauth2_client_secret = utils.create_oauth2_app(
|
||||||
"Dovecot", "dovecot", self.config
|
"Dovecot",
|
||||||
|
"dovecot",
|
||||||
|
self.config.get("dovecot", "oauth2_client_secret"),
|
||||||
|
self.config
|
||||||
)
|
)
|
||||||
hostname = self.config.get("general", "hostname")
|
hostname = self.config.get("general", "hostname")
|
||||||
oauth2_introspection_url = (
|
oauth2_introspection_url = (
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ service auth {
|
|||||||
%{radicale_enabled} mode = 0666
|
%{radicale_enabled} mode = 0666
|
||||||
%{radicale_enabled} user = %{radicale_user}
|
%{radicale_enabled} user = %{radicale_user}
|
||||||
%{radicale_enabled} group = %{radicale_user}
|
%{radicale_enabled} group = %{radicale_user}
|
||||||
%{radicale_enabled} type = auth-legacy
|
|
||||||
%{radicale_enabled}}
|
%{radicale_enabled}}
|
||||||
|
|
||||||
# Auth process is run as this user.
|
# Auth process is run as this user.
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ server {
|
|||||||
|
|
||||||
location ~ ^/(mail/config-v1.1.xml|mobileconfig) {
|
location ~ ^/(mail/config-v1.1.xml|mobileconfig) {
|
||||||
include uwsgi_params;
|
include uwsgi_params;
|
||||||
|
uwsgi_param UWSGI_SCRIPT instance.wsgi:application;
|
||||||
uwsgi_pass modoboa;
|
uwsgi_pass modoboa;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ server {
|
|||||||
%{rspamd_enabled} proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
%{rspamd_enabled} proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
%{rspamd_enabled} }
|
%{rspamd_enabled} }
|
||||||
|
|
||||||
location ~ ^/(api|accounts) {
|
location ~ ^/(api|accounts|autodiscover) {
|
||||||
include uwsgi_params;
|
include uwsgi_params;
|
||||||
uwsgi_param UWSGI_SCRIPT instance.wsgi:application;
|
uwsgi_param UWSGI_SCRIPT instance.wsgi:application;
|
||||||
uwsgi_pass modoboa;
|
uwsgi_pass modoboa;
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ class Radicale(base.Installer):
|
|||||||
"""Additional variables."""
|
"""Additional variables."""
|
||||||
context = super().get_template_context()
|
context = super().get_template_context()
|
||||||
oauth2_client_id, oauth2_client_secret = utils.create_oauth2_app(
|
oauth2_client_id, oauth2_client_secret = utils.create_oauth2_app(
|
||||||
"Radicale", "radicale", self.config)
|
"Radicale",
|
||||||
|
"radicale",
|
||||||
|
self.config.get("radicale", "oauth2_client_secret"),
|
||||||
|
self.config
|
||||||
|
)
|
||||||
hostname = self.config.get("general", "hostname")
|
hostname = self.config.get("general", "hostname")
|
||||||
oauth2_introspection_url = (
|
oauth2_introspection_url = (
|
||||||
f"https://{oauth2_client_id}:{oauth2_client_secret}"
|
f"https://{oauth2_client_id}:{oauth2_client_secret}"
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import stat
|
|||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
|
||||||
|
|
||||||
from . import config_dict_template
|
from . import config_dict_template
|
||||||
from .compatibility_matrix import APP_INCOMPATIBILITY
|
from .compatibility_matrix import APP_INCOMPATIBILITY
|
||||||
@@ -515,14 +514,13 @@ def validate_backup_path(path: str, silent_mode: bool):
|
|||||||
return backup_path
|
return backup_path
|
||||||
|
|
||||||
|
|
||||||
def create_oauth2_app(app_name: str, client_id: str, config) -> tuple[str, str]:
|
def create_oauth2_app(app_name: str, client_id: str, client_secret: str, config) -> tuple[str, str]:
|
||||||
"""Create a application for Oauth2 authentication."""
|
"""Create a application for Oauth2 authentication."""
|
||||||
# FIXME: how can we check that application already exists ?
|
# FIXME: how can we check that application already exists ?
|
||||||
venv_path = config.get("modoboa", "venv_path")
|
venv_path = config.get("modoboa", "venv_path")
|
||||||
python_path = os.path.join(venv_path, "bin", "python")
|
python_path = os.path.join(venv_path, "bin", "python")
|
||||||
instance_path = config.get("modoboa", "instance_path")
|
instance_path = config.get("modoboa", "instance_path")
|
||||||
script_path = os.path.join(instance_path, "manage.py")
|
script_path = os.path.join(instance_path, "manage.py")
|
||||||
client_secret = str(uuid.uuid4())
|
|
||||||
cmd = (
|
cmd = (
|
||||||
f"{python_path} {script_path} createapplication "
|
f"{python_path} {script_path} createapplication "
|
||||||
f"--name={app_name} --skip-authorization "
|
f"--name={app_name} --skip-authorization "
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1d701353d900f4b6e2f7ffba6f6b7a46d304f58b
|
03b124501ec1a61eaa3063ac9fb839fdbc64f00c
|
||||||
Reference in New Issue
Block a user