Public: anyone can read this; the crew can change it.

"Send mail from this AWS account" makes the SES identity, its DKIM records and the mail key in order, once #18171

opened this

Closed 5h 11m ago

An admin can now set up sending mail from an AWS account in one confirm, on the page or in the terminal. It makes the SES identity, then the DKIM records, then the mail key, and a second run makes nothing new.

Notes

opened this

An admin can now set up sending mail from an AWS account in one confirm, on the page or in the terminal. It makes the SES identity, then the DKIM records, then the mail key, and a second run makes nothing new. The new tests, the changed AWS-writes test, the terminal and mail-key suites and the gate pass, and tsc is clean. I didn't run the full suite or the preview; the forge's check does that on this push.

What changed

  • Confirm page and terminal: /settings/secrets/aws-mail is linked from the Secrets card. It takes a sending subdomain and region, lists what will be made, and confirms with a POST. In the terminal, w on the Secrets screen asks for the subdomain, shows the same plan, then runs it (src/tui/screens/aws_mail.ts).
  • Steps: src/cloud/ses_setup.ts takes every AWS and DNS call as an argument, so tests can run it against recorded services.
    1. It makes the SES identity, or keeps one that exists.
    2. It writes the three DKIM CNAMEs at Cloudflare: kept if they read right, changed if the name holds another value, made otherwise.
    3. It makes the forge-mail-send IAM user with a policy allowing only ses:SendRawEmail from that one identity.
    4. It derives the SMTP password and seals it as the forge-scope mail key, with MAIL_FROM set to forge@<subdomain>.
  • Second run: once the forge holds a mail key, no second access key is made.
  • No secret shown: the secret access key and SMTP password go from AWS's answer straight to setMailKey. They appear in no step, error, page, screen or log.
  • AWS writes: src/cloud/aws_call.ts can now send the one SES write, ses:CreateEmailIdentity. It is a POST to /v2/email/identities for one domain name, refused on a read-only account.
  • Test change: I replaced the "SES writes are not listed" test in test/aws-writes.test.ts, because it asserted the opposite of this change.
  • Tests and docs: test/ses-setup.test.ts runs a recorded AWS and Cloudflare end to end and searches every output for the secrets. The how-to is docs/features/aws-mail.md. Routes are marked admin in src/http/marks/settings.json.

Reused: awsCall and its write allowlist, accountCall, Cloudflare's zoneOf and cloudflare, withCloudflare (now exported), setMailKey, gatedFetch, pageHead, row and rowList. The gate flagged sesInputWords as similar to nameProblem, but they check different things, so I kept it.

Left out

  • No API route or MCP tool.
  • No undo (DeleteEmailIdentity).
  • The terminal fixes the region at us-east-1 and only works when exactly one writable AWS account and one writable Cloudflare account exist. With more, it points to the page, which has selects.
  • The page flow has no browser look picture. The commit says No look.

Try it: open /settings/secrets/aws-mail as an admin on the preview, enter mail.example.com, and read the plan. Confirming needs a writable AWS account and a writable Cloudflare account, so a real run is not possible on the preview; the tests cover the run.

🤖 Generated with Claude Code

Closes #18135

10 earlier comments
commented

An admin can now set up sending mail from an AWS account in one confirm, on the page or in the terminal. It makes the SES identity, then the DKIM records, then the mail key, and a second run makes nothing new. The new tests, the changed AWS-writes test, the terminal and mail-key suites and the gate pass, and tsc is clean. I didn't run the full suite or the preview; the forge's check does that on this push.

What changed

  • Confirm page and terminal: /settings/secrets/aws-mail is linked from the Secrets card. It takes a sending subdomain and region, lists what will be made, and confirms with a POST. In the terminal, w on the Secrets screen asks for the subdomain, shows the same plan, then runs it (src/tui/screens/aws_mail.ts).
  • Steps: src/cloud/ses_setup.ts takes every AWS and DNS call as an argument, so tests can run it against recorded services.
    1. It makes the SES identity, or keeps one that exists.
    2. It writes the three DKIM CNAMEs at Cloudflare: kept if they read right, changed if the name holds another value, made otherwise.
    3. It makes the forge-mail-send IAM user with a policy allowing only ses:SendRawEmail from that one identity.
    4. It derives the SMTP password and seals it as the forge-scope mail key, with MAIL_FROM set to forge@<subdomain>.
  • Second run: once the forge holds a mail key, no second access key is made.
  • No secret shown: the secret access key and SMTP password go from AWS's answer straight to setMailKey. They appear in no step, error, page, screen or log.
  • AWS writes: src/cloud/aws_call.ts can now send the one SES write, ses:CreateEmailIdentity. It is a POST to /v2/email/identities for one domain name, refused on a read-only account.
  • Test change: I replaced the "SES writes are not listed" test in test/aws-writes.test.ts, because it asserted the opposite of this change.
  • Tests and docs: test/ses-setup.test.ts runs a recorded AWS and Cloudflare end to end and searches every output for the secrets. The how-to is docs/features/aws-mail.md. Routes are marked admin in src/http/marks/settings.json.

Reused: awsCall and its write allowlist, accountCall, Cloudflare's zoneOf and cloudflare, withCloudflare (now exported), setMailKey, gatedFetch, pageHead, row and rowList. The gate flagged sesInputWords as similar to nameProblem, but they check different things, so I kept it.

Left out

  • No API route or MCP tool.
  • No undo (DeleteEmailIdentity).
  • The terminal fixes the region at us-east-1 and only works when exactly one writable AWS account and one writable Cloudflare account exist. With more, it points to the page, which has selects.
  • The page flow has no browser look picture. The commit says No look.

Try it: open /settings/secrets/aws-mail as an admin on the preview, enter mail.example.com, and read the plan. Confirming needs a writable AWS account and a writable Cloudflare account, so a real run is not possible on the preview; the tests cover the run.

🤖 Generated with Claude Code

commented

<!-- look-pages ab8f05703ec1 --> Look pages for ab8f057, from the gate:

  • look pages (none): this pull changes src/web/pages/secrets.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

This fixes the two failures the check reported on the AWS mail flow. I pushed the fix to the branch. test/ses-setup.test.ts and test/design-audit.test.ts pass locally (11 tests) and bun x tsc --noEmit is clean. I did not run the full suite; the forge runs it on the push.

  • Poll loop: the test waited for "Nothing new" with a hand-written 100-iteration loop that carried on if it never appeared. It now uses the shared pollUntil helper from test/helpers/poll.ts, which throws if the screen never says it.
  • Audit entry: the new /settings/secrets/aws-mail page had no entry in docs/design/audit.md. I added one.

bun scripts/gate.ts --fix changed nothing. It still prints two "one implementation?" notes on test helpers (key in test/ses-setup.test.ts, spy in test/aws-writes.test.ts). I left them as they were; they are not what the check failed on.

commented

I pushed one commit (empty, no file changes) that names the page this pull changes and the issue it serves. That answers the look-pages and issue-number items. The other two guards already pass, so I changed no code for them.

  • Look page: the commit carries Looks: /settings/secrets/aws-mail, the page this pull adds in src/web/pages/secrets.ts. The gate could not trace the route itself, so the line says it.
  • Issue number: the commit carries Direction: send mail from this AWS account, in order and once (#18135).
  • Both doors: nothing new to do. The terminal screen src/tui/screens/aws_mail.ts and the how-to were already in the earlier commits for this pull. I did not re-run the gate's door rule.
  • Dead exports: test/unused-exports.test.ts passes. It prints a note about stale allowlist entries in crawl.ts, migrate.ts, watch_probe_default.ts and reach_default.ts. None of them are files this pull touches, so I left them.
  • Module-level state: test/module-state.test.ts passes. I added no module-level Map, Set or array that a function writes to.

I ran only those two tests this time (7 pass). The forge runs the full check on the push.

commented

<!-- look-pages 048f0aa0f296 --> Look pages for 048f0aa, from the gate:

  • look pages (none): "Looks: /settings/secrets/aws-mail" is not a page of app.looks in forge.json; this pull changes src/web/pages/secrets.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

I pushed one more empty commit, which swaps the look line for a "No look" line. The gate refused Looks: /settings/secrets/aws-mail because that path is not in app.looks in forge.json. The new line gives the reason: the page is a signed-in settings page, outside app.looks, and the tests render it and read it back.

I did not add the page to app.looks. That would change which pages the forge photographs on every pull, which is the reviewer's decision, and I'm leaving it to them.

The other three items are unchanged from my last message, and I did not re-run those tests this time. The Direction: send mail from this AWS account, in order and once (#18135) line is repeated in this commit. The terminal screen and how-to are already in earlier commits. The dead-exports and module-state tests passed on the last push.

commented

The failing check is fixed and pushed: /settings/secrets/aws-mail now names its Server-Timing phases. I only ran the timing sweep, type check and gate, not the full suite. The sweep passes (4 tests), bun x tsc --noEmit is clean, and the gate only prints similarity hints, which I left alone.

  • What changed: awsMailPage in src/web/pages/secrets.ts now reports session, accounts (the mail-account lookup) and render, the same way the secrets page does.
  • What I left out: no behaviour, markup or terminal change, so the commit says No door: with the reason. Nothing else from the earlier review was touched.
  • To try it: run bun test test/server-timing-sweep.test.ts, or request the page as an admin and read the Server-Timing header.

Review block: none needed, since the page's output is unchanged.

commented

This update fixes the signed-POST bypass in the write allowlist, the leaked access keys, and the concurrent-confirm race. The two ses-setup and aws-writes test files pass (24 tests) and tsc is clean. I did not run the whole suite; the forge's check does that on the push. bun scripts/gate.ts exits clean, with only its similarity notes about near-duplicate functions printed.

What changed

  • High, write allowlist (src/cloud/aws_call.ts): A call with post set is now never treated as a read, whatever operation is named. It must be an exact service:operation in WRITES. The read-only check then runs, and then the check that it is CreateEmailIdentity, to /v2/email/identities, with exactly one domain in the body. AwsAsk now has separate typed members for the GET and the POST, so the (ask as {...}) casts are gone. test/aws-writes.test.ts has a new test: {path, post, operation:"ListFoo"} is refused on a read-only account and on a writable one.
  • Medium, lost keys (src/cloud/ses_setup.ts): If seal fails, the access key just made is deleted with iam:DeleteAccessKey. Before creating a key it lists the user's keys, and if there are already two (IAM's limit) it removes them as leftovers.
  • Medium, concurrent confirms: keyHeld() is re-checked right before sealing. A run that lost the race deletes its own key and reports that another run sealed first. Tests cover all three cases.
  • Smaller: A kept mail key now says its policy covers only the identity it was made for, which may not be the new subdomain. The stray blank line at the end of docs/features/aws-mail.md is gone.

Where I did not do what was asked

  • Single in-flight run: I did not hold one run per forge in the app instance. The App type has nowhere for it, and a module-level map is exactly what the "no process-wide state" check refuses. The re-check before sealing is race-free because it and seal run with no await between them.
  • Stale-key cleanup: It only runs when the user already has two keys. A run that is at that limit while another run is mid-flight could delete the other run's unsealed key. That is a narrow window, and I did not close it.
  • Comparing MAIL_FROM: I did not compare it with the held key's MAIL_FROM, because that would mean opening the secret. The run words say it instead.

I changed no page, terminal screen or feature how-to, so there is no review block.

commented

Declined: already done on main in bd73c122d. Main now contains an independent implementation of this feature, "Mail from the owner's AWS account: the forge sets up SES, its DNS records and the mail key in one confirmed step (#18119)". Run log: https://forge.open-platform.sh/trevato/forge/runs/01m90exbd8y1x1ygv2m18djckh Left open: someone has spoken on this pull.

commented

Closed by the crew: superseded, its change is already on main in bd73c122.

commented

Left #18135 open: 3 unticked items remain (One confirm page says what will be made: an SES identity for a sending subdomain with DKIM, the send-only IAM user, the DKIM DNS records in the DNS account the forge already holds.; Confirming makes them in that order and seals the SMTP credential as the forge's mail key. The secret is never shown.; A second run makes nothing new.).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs