Skip to content

[M2.2c3b] Deliver identity codes over verified SMTP TLS - #47

Merged
samuelmbabhazi merged 2 commits into
mainfrom
feat/m2.2c3b-smtp-delivery
Nov 5, 2026
Merged

samuelmbabhazi merged 2 commits into
mainfrom
feat/m2.2c3b-smtp-delivery

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Task

M2.2c3b, part of #21. Depends on #46; base feat/m2.2c3a-private-mail-queue.

What changed and why

Add SMTP delivery over implicit TLS with mandatory certificate-chain/hostname verification and TLS 1.2 minimum. Configure the SMTP host, sender, optional credentials and optional public CA bundle through validated/redacting application configuration. A ten-second inactivity timeout and twenty-second total deadline bound delivery; sockets close on both success and failure.

Emails link to a clean verification/reset page and provide a separate code to paste, keeping bearer credentials out of URLs. Public API URLs must be bare origins and use HTTPS in production. emailjs is pinned to MIT-licensed version 5.0.4. Providers must support implicit TLS (normally port 465); STARTTLS/plaintext SMTP is outside this implementation.

Validation

  • Thirty-eight integration tests pass, including four tests against a real loopback TLS SMTP server: successful authenticated delivery, untrusted certificate rejection, hostname mismatch rejection and header injection/expired credential handling.
  • Unit tests enforce the total deadline, transport-error redaction, socket cleanup and SMTP/public-origin configuration constraints.
  • Workspace types, builds and TypeScript tests pass; lint passes after fixture type checks.
  • No message was sent to an external email service; TLS keys and the test CA are generated at runtime and cleaned up.

Security considerations

There is no TLS verification bypass. SMTP credentials are exposed only to the transport and protocol logging is disabled. Untrusted certificates fail before SMTP authentication. Transport errors are opaque before the durable worker sees them. Production signup endpoints still await HTTP integration in M2.2c4.

Checklist

  • M2.2c3 delivery acceptance checked; HTTP flows remain open
  • Lint, types, builds, unit and integration tests pass
  • Real TLS negative tests and deadline tests included
  • No shell invocation, committed key/certificate or credential URL
  • Durable delivery remains coupled to audited commands
  • Configuration example, SPEC and threat model updated

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2c3a-private-mail-queue branch from 38054d9 to 0c74633 Compare November 5, 2026 12:15
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.2c3a-private-mail-queue to main November 5, 2026 12:15
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2c3b-smtp-delivery branch from 6fdde0c to 21c05e5 Compare November 5, 2026 12:15
@samuelmbabhazi
samuelmbabhazi merged commit f11ec13 into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2c3b-smtp-delivery branch November 5, 2026 12:16
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
Browser session guards now reject unauthenticated requests by default
and require both an exact configured Origin and a session-bound CSRF
header for mutations. Explicit anonymous routes still enforce Origin on
writes. HTTPS cookies are host-bound, Secure and SameSite=Strict; only
the CSRF cookie is JavaScript-readable.

The rate guard applies the persisted quotas before DTO processing,
normalizes account subjects, and returns Retry-After and quota metadata.
Duplicate credentials and bearer-to-cookie fallback fail closed. Global
registration and account endpoints follow in M2.2c4b.

Validation: API lint, strict typecheck and all 92 unit tests pass,
including eight new HTTP/cookie boundary tests. Tests cover cross-site
requests, missing or mismatched CSRF, duplicate cookies, untrusted
forwarded IPs and quota responses. No database migration or
generated-contract change in this slice.

Security: the CSRF header joins the logging redaction list. No raw
credentials are logged; authentication reuses the validated session
service. This PR is stacked on #47; do not merge automatically.

- [x] M2.2c4a acceptance criteria documented and met
- [x] Relevant tests, lint and typecheck pass locally
- [x] No new shell invocation or secret exposure path
- [x] No new business state mutation; session activity and throttle
counters reuse existing stores
- [x] Threat model and plan updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant