mirror of
https://github.com/Mailu/Mailu.git
synced 2025-03-03 14:52:36 +02:00
Reflect the data from the POST
This commit is contained in:
parent
14931c4acd
commit
3e6f3a95a4
@ -2,6 +2,7 @@ from mailu.internal import internal
|
|||||||
|
|
||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
import flask
|
import flask
|
||||||
|
import xmltodict
|
||||||
|
|
||||||
@internal.route("/autoconfig/mozilla")
|
@internal.route("/autoconfig/mozilla")
|
||||||
def autoconfig_mozilla():
|
def autoconfig_mozilla():
|
||||||
@ -50,36 +51,48 @@ def autoconfig_microsoft_json():
|
|||||||
else:
|
else:
|
||||||
return flask.abort(404)
|
return flask.abort(404)
|
||||||
|
|
||||||
@internal.route("/autoconfig/microsoft", methods=['GET', 'POST'])
|
@internal.route("/autoconfig/microsoft", methods=['POST'])
|
||||||
def autoconfig_microsoft():
|
def autoconfig_microsoft():
|
||||||
# https://docs.microsoft.com/en-us/previous-versions/office/office-2010/cc511507(v=office.14)?redirectedfrom=MSDN#Anchor_3
|
# https://docs.microsoft.com/en-us/previous-versions/office/office-2010/cc511507(v=office.14)?redirectedfrom=MSDN#Anchor_3
|
||||||
hostname = app.config['HOSTNAME']
|
hostname = app.config['HOSTNAME']
|
||||||
xml = f'''<?xml version=\"1.0\" encoding=\"utf-8\" ?>
|
try:
|
||||||
<Autodiscover xmlns=\"http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006\">
|
xmlRequest = (flask.request.data).decode("utf-8")
|
||||||
<Response xmlns=\"http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a\">
|
xml = xmltodict.parse(xmlRequest[xmlRequest.find('<'):xmlRequest.rfind('>')+1])
|
||||||
<Account>
|
schema = xml['Autodiscover']['Request']['AcceptableResponseSchema']
|
||||||
<AccountType>email</AccountType>
|
if schema != 'http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a':
|
||||||
<Action>settings</Action>
|
return flask.abort(404)
|
||||||
<Protocol>
|
email = xml['Autodiscover']['Request']['EMailAddress']
|
||||||
<Type>IMAP</Type>
|
xml = f'''<?xml version=\"1.0\" encoding=\"utf-8\" ?>
|
||||||
<Server>{hostname}</Server>
|
<Autodiscover xmlns=\"http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006\">
|
||||||
<Port>993</Port>
|
<Response xmlns="{schema}">
|
||||||
<DomainRequired>on</DomainRequired>
|
<Account>
|
||||||
<SPA>off</SPA>
|
<AccountType>email</AccountType>
|
||||||
<Encryption>TLS</Encryption>
|
<Action>settings</Action>
|
||||||
</Protocol>
|
<Protocol>
|
||||||
<Protocol>
|
<Type>IMAP</Type>
|
||||||
<Type>SMTP</Type>
|
<Server>{hostname}</Server>
|
||||||
<Server>{hostname}</Server>
|
<Port>993</Port>
|
||||||
<Port>465</Port>
|
<LoginName>{email}</LoginName>
|
||||||
<DomainRequired>on</DomainRequired>
|
<DomainRequired>on</DomainRequired>
|
||||||
<SPA>off</SPA>
|
<SPA>off</SPA>
|
||||||
<Encryption>TLS</Encryption>
|
<SSL>on</SSL>
|
||||||
</Protocol>
|
</Protocol>
|
||||||
</Account>
|
<Protocol>
|
||||||
</Response>
|
<Type>SMTP</Type>
|
||||||
</Autodiscover>'''
|
<Server>{hostname}</Server>
|
||||||
return flask.Response(xml, mimetype='text/xml', status=200)
|
<Port>465</Port>
|
||||||
|
<LoginName>{email}</LoginName>
|
||||||
|
<DomainRequired>on</DomainRequired>
|
||||||
|
<SPA>off</SPA>
|
||||||
|
<SSL>on</SSL>
|
||||||
|
</Protocol>
|
||||||
|
</Account>
|
||||||
|
</Response>
|
||||||
|
</Autodiscover>'''
|
||||||
|
return flask.Response(xml, mimetype='text/xml', status=200)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return flask.abort(400)
|
||||||
|
|
||||||
@internal.route("/autoconfig/apple")
|
@internal.route("/autoconfig/apple")
|
||||||
def autoconfig_apple():
|
def autoconfig_apple():
|
||||||
|
@ -73,3 +73,4 @@ webencodings==0.5.1
|
|||||||
Werkzeug==2.0.2
|
Werkzeug==2.0.2
|
||||||
WTForms==2.3.3
|
WTForms==2.3.3
|
||||||
WTForms-Components==0.10.5
|
WTForms-Components==0.10.5
|
||||||
|
xmltodict==0.12.0
|
||||||
|
@ -25,3 +25,4 @@ srslib
|
|||||||
marshmallow
|
marshmallow
|
||||||
flask-marshmallow
|
flask-marshmallow
|
||||||
marshmallow-sqlalchemy
|
marshmallow-sqlalchemy
|
||||||
|
xmltodict
|
||||||
|
Loading…
x
Reference in New Issue
Block a user