From cdc92aa65be068c1e4b79d6d238698ba3887bfb4 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Thu, 10 Mar 2022 10:29:11 +0100 Subject: [PATCH] Mobileconfig apple style --- core/admin/mailu/internal/views/autoconfig.py | 89 +++++++++++++++++++ core/nginx/conf/nginx.conf | 6 ++ 2 files changed, 95 insertions(+) diff --git a/core/admin/mailu/internal/views/autoconfig.py b/core/admin/mailu/internal/views/autoconfig.py index b93794b3..7c549900 100644 --- a/core/admin/mailu/internal/views/autoconfig.py +++ b/core/admin/mailu/internal/views/autoconfig.py @@ -72,3 +72,92 @@ def autoconfig_microsoft(): \r\n''' return flask.Response(xml, mimetype='text/xml', status=200) + +@internal.route("/autoconfig/apple") +def autoconfig_apple(): + # https://developer.apple.com/business/documentation/Configuration-Profile-Reference.pdf + hostname = app.config['HOSTNAME'] + sitename = app.config['SITENAME'] + xml = f''' + + + +PayloadContent + + +EmailAccountDescription +{sitename} +EmailAccountName +{hostname} +EmailAccountType +EmailTypeIMAP +EmailAddress + +IncomingMailServerAuthentication +EmailAuthPassword +IncomingMailServerHostName +{hostname} +IncomingMailServerPortNumber +993 +IncomingMailServerUseSSL + +IncomingMailServerUsername + +IncomingPassword + +OutgoingMailServerAuthentication +EmailAuthPassword +OutgoingMailServerHostName +{hostname} +OutgoingMailServerPortNumber +465 +OutgoingMailServerUseSSL + +OutgoingMailServerUsername + +OutgoingPasswordSameAsIncomingPassword + +PayloadDescription +{sitename} +PayloadDisplayName +{hostname} +PayloadIdentifier +{hostname}.email +PayloadOrganization + +PayloadType +com.apple.mail.managed +PayloadUUID +72e152e2-d285-4588-9741-25bdd50c4d11 +PayloadVersion +1 +PreventAppSheet + +PreventMove + +SMIMEEnabled + +disableMailRecentsSyncing + + + +PayloadDescription +{hostname} - E-Mail Account Configuration +PayloadDisplayName +E-Mail Account {hostname} +PayloadIdentifier +E-Mail Account {hostname} +PayloadOrganization +{hostname} +PayloadRemovalDisallowed + +PayloadType +Configuration +PayloadUUID +56db43a5-d29e-4609-a908-dce94d0be48e +PayloadVersion +1 + +\r\n''' + return flask.Response(xml, mimetype='text/xml', status=200) diff --git a/core/nginx/conf/nginx.conf b/core/nginx/conf/nginx.conf index 87775f80..4edb5dcd 100644 --- a/core/nginx/conf/nginx.conf +++ b/core/nginx/conf/nginx.conf @@ -132,6 +132,12 @@ http { include /etc/nginx/proxy.conf; proxy_pass http://$admin; } + # apple mobileconfig + location ^~ /mobileconfig { + rewrite ^ /internal/autoconfig/apple break; + include /etc/nginx/proxy.conf; + proxy_pass http://$admin; + } {% if TLS_FLAVOR == 'mail-letsencrypt' %} location ^~ /.well-known/acme-challenge/ {