Per-domain SMTP gateway management (ORM, REST, CLI) - #96
Open
gott-alexander wants to merge 5 commits into
Open
Conversation
Adds the grommunio-admin API surface for the per-domain SMTP-gateway
table that gromox reads at SMTP delivery time.
Changes:
* New SQL migration `sql/001-domain-smtp-gateway.sql` that creates
the `domain_smtp_gateway` table (one row per domain) and an
index on `enabled`. Compatible with MariaDB 10.5+ and MySQL 8+.
* New ORM model `orm.domain_smtp_gateway.DomainSmtpGateway`
registered in `orm/__init__.py`.
* New REST endpoint mounted at
`GET /api/v1/domains/<id>/smtpGateway`
`PUT /api/v1/domains/<id>/smtpGateway`
`DELETE /api/v1/domains/<id>/smtpGateway`
The endpoint re-emits the gromox config-reload signal so the
lookup table is picked up without restarting the daemons.
* New CLI subcommand
`grommunio-admin domain smtp-gateway {set,show,delete,list}`
for headless configuration. Passwords are masked in `show` and
`list` output.
* OpenAPI 3 spec updated: `/domains/{domainID}/smtpGateway` path,
`domainSmtpGateway` / `domainSmtpGatewayWrite` schemas.
* `res/openapi.json` regenerated from `openapi.yaml`.
Companion changes: grommunio/gromox#<PR> (service registry +
`cu_send_mail` integration) and grommunio/admin-web#<PR>
(SMTP-gateway tab in the domain details).
The domain_smtp_gateway table is now created by gromox's dbop module (schema version 134, lib/dbop_mysql.cpp), both on fresh installs (gromox-dbop -C) and upgrades (gromox-dbop -U / mysql_adaptor schema_upgrade). The standalone SQL file and its ORM docstring reference are therefore obsolete.
Nothing consumes the from_address column anymore: outbound smart-host routing (and any envelope rewriting) is the MTA's job, which evaluates the domain_smtp_gateway table directly (see doc/mta-smart-hosts.rst in gromox). Drop the column from the ORM, CLI, API docs and endpoint documentation so the UI does not offer a field without effect.
The MTA evaluates domain_smtp_gateway live, so no service restart is needed after changes; reload_gromox() only caused pointless gromox-delivery restarts. Also drop unused imports and update comments that still described the removed in-gromox delivery hook (resolve_smtp_url_for_sender) and the outgoing_smtp_url fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds management of per-domain outbound SMTP gateways (smart-hosts): an ORM
model mirroring the
domain_smtp_gatewaytable, REST endpoints and a CLIcommand. The table itself is created by gromox's dbop (schema version 134);
this repository only reads and writes it.
Changes
orm/domain_smtp_gateway.py(new):DomainSmtpGatewaymodel — mirror ofthe dbop table, including validation of the encryption values and the
port range. Any schema change here must be reflected in gromox's
lib/dbop_mysql.cppand vice versa.endpoints/domain/smtp_gateway.py(new):GET/PUT/DELETE /api/v1/domains/<ID>/smtpGateway, guarded byDomainAdmin (write) / DomainAdminRO (read) permissions. The GET response
censors the password and reports a
passwordSetflag instead; a PUTwith an empty password keeps the stored one (usual password-field UX),
so credentials never need to be sent back to the client.
cli/domain_smtp_gateway.py(new):grommunio-admin domain smtp-gateway set/show/delete/list— same operations for the shell,with the password masked in
show.res/openapi.yaml: schemas and endpoints documented.cli/domain.py,endpoints/domain/__init__.py,orm/__init__.py:registration of the new modules.
No service restarts are triggered on changes: the consumer of the table
(the MTA) evaluates it live.
Verification
Built against the official spec; PUT/GET/DELETE round-trip including the
password-keep behaviour, rejection of invalid encryption values and port
ranges (400), permission checks, and CLI set/show/list/delete against a
test database.