refactor(admin): remove dead SMTP admin form + clean up stale rows (LC-77-SMTP-SEAL, #200) #204
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-77-smtp-seal"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #200 (LC-77-SMTP-SEAL).
Investigation finding rerouted the scope
The original ticket plan was "migrate SMTP password from plaintext to AES-256-GCM-sealed storage" mirroring the LC-77
imap_inbox_configpattern. The first thing this branch did was grep for actual readers of the password column. Result:routes::admin::post_settingswritessmtp_pass(line 474).routes::admin::get_settingsreads it back, just to re-display in the admin form.mail::Mailer::from_env(line 29) reads SMTP config exclusively from theSMTP_*env vars, as documented in its 14-line module doc-comment.The
settings.dbSMTP rows are dead storage. The plaintext password sitting there was the only real consequence of the form; sealing the column would have added crypto plumbing around a value no code consults.The real fix is to stop populating the column. This PR removes the SMTP admin form, drops the dead model, and ships a migration that DELETEs the legacy
smtp_*rows. Existing operator deployments get their stale plaintext password dropped at next startup, and new deployments never accumulate the row in the first place.What changed
routes/admin.rs:SettingsFormreduced to an empty struct (the form has no inputs anymore);get_settingsstops readingsmtp_*;SettingsPageconstruction drops thesmtp_*fields;post_settingsbecomes a no-op redirect retained so a stale browser POST doesn't 404. Comment block at the struct site names the finding so a future contributor doesn't reintroduce the pattern.views/admin.rs:SettingsPagestruct dropssmtp_host/smtp_port/smtp_user/smtp_from/saved.templates/admin/settings.html: SMTP form section replaced with an informational banner: "SMTP is configured via environment variables, not the admin UI. SetSMTP_HOST... and restart. SeeREADME.md."models/settings.rs: deleted.SiteSettingswas defined and re-exported but never constructed or read anywhere - pure dead code unrelated to this PR but unrelated cleanup it costs zero to fold in.models/mod.rs: drop theSiteSettingsre-export.migrations/settings/0006_drop_smtp_settings.sql(new): idempotentDELETE FROM settings WHERE key IN ('smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', 'smtp_from').Test plan
tests/db_smtp_settings_cleanup.rs::migration_drops_pre_existing_smtp_settings_rows: inserts the five legacy keys, runs the migration SQL, asserts gone; also asserts unrelated rows survive; also asserts idempotent re-run.--features standalone(default) and--no-default-features --features saas.cargo clippy --tests -- -D warningsclean.cargo fmt --checkclean.settings/0006migration appended (CLAUDE.md test-maintenance category 2). No drift expected from this PR going forward; future migrations follow the same pattern.Anti-scope
SMTP_*env var loader inmail.rs. That is the actual SMTP config surface and stays as-is.Closes
#200 (LC-77-SMTP-SEAL).