Allow specific users to send email from any address

This commit is contained in:
Florent Daigniere
2021-08-02 19:18:42 +02:00
parent a5534a34dc
commit facc4b6427
4 changed files with 8 additions and 1 deletions

View File

@@ -133,10 +133,13 @@ def postfix_sender_map(sender):
@internal.route("/postfix/sender/login/<path:sender>")
def postfix_sender_login(sender):
has_wildcard_senders = bool(flask.current_app.config["WILDCARD_SENDERS"])
wildcard_senders = flask.current_app.config["WILDCARD_SENDERS"].lower().split(',') if has_wildcard_senders else []
localpart, domain_name = models.Email.resolve_domain(sender)
if localpart is None:
return flask.abort(404)
return flask.jsonify(",".join(wildcard_senders)) if has_wildcard_senders else flask.abort(404)
destination = models.Email.resolve_destination(localpart, domain_name, True)
destination = [*destination, *wildcard_senders] if destination else [*wildcard_senders]
return flask.jsonify(",".join(destination)) if destination else flask.abort(404)