doveauth-http: deploying HTTP route for account creation

This commit is contained in:
missytake
2023-12-01 18:32:45 +01:00
parent ccfbb59e17
commit fbcf071e89
5 changed files with 26 additions and 0 deletions

View File

@@ -8,10 +8,12 @@ version = "0.1"
dependencies = [
"aiosmtpd",
"flask",
"gunicorn",
]
[project.scripts]
doveauth = "chatmaild.doveauth:main"
doveauth-http = "chatmaild.web:main"
filtermail = "chatmaild.filtermail:main"
[tool.pytest.ini_options]

View File

@@ -0,0 +1,10 @@
[Unit]
Description=HTTP endpoint for creating chatmail accounts
[Service]
ExecStart=/usr/local/bin/gunicorn --timeout 60 -b :3691 -w 1 chatmaild.web:main
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target

View File

@@ -1,5 +1,6 @@
from flask import Flask, jsonify, request
import time
import os
from database import Database
from util import gen_password, get_valid_email_addr, encrypt_password
@@ -37,3 +38,11 @@ def create_app_from_db(db):
)
return app
def main():
"""(debugging-only!) serve http account creation Web API on localhost"""
db_path = os.getenv("CHATMAIL_DATABASE", "/home/vmail/passdb.sqlite")
app = create_app_from_db_path(db_path)
if __name__ == "__main__":
app.run(debug=True, host="localhost", port=3691)

View File

@@ -46,6 +46,7 @@ def _install_chatmaild() -> None:
for fn in (
"doveauth",
"doveauth-http",
"filtermail",
):
files.put(

View File

@@ -42,6 +42,10 @@ http {
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /new_email {
proxy_pass http://localhost:3691/;
}
}
}