Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/self-host/config-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ See [Model providers](./model-providers.md).
Logo in email headers.
- **`email.privacyUrl`** *string or null, default `null`*\
A privacy page linked in email footers.
- **`email.transport`** *`"ses"` or `"coderhelm"`, default `"ses"`*\
How email is sent until an admin changes it in Settings, Emails: this install's own Amazon SES, or CoderHelm's mail service (needs the install registered for hybrid).

See [Email](./email.md).

Expand All @@ -107,8 +109,8 @@ A self-hosted install is one organization: sign-up is closed to everyone else. A
The CodeBuild sandbox that runs a repo's build and checks during runs.
- **`integrations.logAnalyzer`** *boolean, default `true`*\
Scheduled log analysis for AWS accounts teams connect.
- **`integrations.weeklySummary`** *boolean, default `true`*\
The Monday summary email.
- **`integrations.weeklySummary`** *boolean, default `false`*\
The Monday summary email's starting value. An install admin turns it on or off in Settings, Emails; that choice wins.
- **`integrations.weeklySummaryListedTeamsOnly`** *boolean, default `false`*\
Only teams with a rollout list get the summary.

Expand Down
41 changes: 40 additions & 1 deletion docs/self-host/email.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@ description: How CoderHelm sends email from your AWS account with Amazon SES, an
order: 7
---

CoderHelm sends run results, invites, token limit warnings, the weekly summary and account emails through Amazon SES in your account, from `email.from`.
A self-hosted install sends the emails it needs, and nothing else until you turn it on. It sends them through Amazon SES in your account, from `email.from`, or, if you choose, through CoderHelm's mail service (see [Send through CoderHelm](#send-through-coderhelm)). It never emails a CoderHelm address.

## Which emails it sends

**Settings, Emails** (install admins) lists them all.

| Email | Kind | Why |
|---|---|---|
| Sign-up codes and password resets | Essential | Nobody can verify their address or get back in without them. Amazon Cognito makes, sends and checks them inside your install. |
| Team invites | Essential | The only way an invited person learns how to join. |
| Plugin approval requests | Essential | A named approver must approve a plugin draft before it publishes. |
| Knowledge source sign-in alerts | Essential | Tells admins a knowledge source stopped syncing. |
| Token limit warnings | Essential | Tells the team before work stops at the monthly limit. Each person can turn these off. |
| Support ticket updates | Essential | Replies and status changes on tickets someone filed. |
| Webhook endpoint turned off | Essential | Tells a team's admins when CoderHelm stopped sending to an endpoint that failed for days. |
| Two-factor lockout alerts | Essential | Tells admins and owners when someone's two-factor sign-in was paused after too many wrong codes. |
| Update notices | Essential | New releases, finished or failed updates, address changes, to install admins. |
| Test email | Essential | Only when an admin presses **Send test email** in Setup. |
| Weekly summary | Optional, **off** | The Monday email with each team's week. |
| Welcome email | Optional, **off** | A short hello after someone signs up. |

Optional emails stay off until an install admin turns them on in **Settings, Emails**; no redeploy is needed. `integrations.weeklySummary: true` in the config starts the summary on instead. Each person can still turn emails off for themselves in **Settings, Notifications** or with an email's unsubscribe link. The hosted CoderHelm service is unchanged: its weekly summary goes to everyone who hasn't unsubscribed.

## The identity

Expand Down Expand Up @@ -40,3 +61,21 @@ The email templates are created by the email stack with your URLs filled in. `em
Every link CoderHelm sends from your install points at your install: emails (run results, invites, approvals, the weekly summary and its unsubscribe link), Slack and Teams cards, Jira comments and GitHub comments all use your own address. The header logo loads from your install (`<your address>/favicon.svg`) unless you set `email.logoUrl`, so opening an email never calls CoderHelm's servers. Support and "reply to unsubscribe" go to `email.supportInbox` (by default `email.from`), never to CoderHelm support. The only coderhelm.com links left are the public docs on docs.coderhelm.com.

If the install doesn't know its own address (no `APP_URL` and `API_URL`, and the CloudFront address not yet readable from SSM), links stay relative rather than pointing anywhere else, the services log an error at start, and **Settings, then Setup** fails **Web address answers** until a deploy sets it.

## Send through CoderHelm

If you'd rather not set up SES (verifying a sender and leaving the sandbox), an install registered for [hybrid](./hybrid.md) can send its email through CoderHelm's mail service instead. Choose **Through CoderHelm** in **Settings, Emails**, or in the install guide's **Optional setup**, or set `"email": { "transport": "coderhelm" }`. It is off unless you pick it, and it applies to every email the install sends (invites, approvals, alerts, update notices, and the optional ones you turned on). Sign-up codes stay with Amazon Cognito inside your install: CoderHelm never sees them.

If CoderHelm's mail service can't be reached, the email fails and shows in **Deliveries** and **Settings, Setup**. Nothing is sent another way instead.

**What CoderHelm sees:** each recipient's address, the template id and its parameters (names, PR titles and run links in the weekly summary). It keeps only delivery metadata after sending: the template id, a shortened address (`d***@example.com`) and whether it was delivered, for 3 days. It never keeps the email itself.

**How it works:**

- Your install sends a template id and its parameters, signed with its registration secret, never a subject or HTML. CoderHelm writes the email from its own templates.
- Mail comes from `notifications@notify.coderhelm.com` with your install's address as the name (`acme.coderhelm.com via CoderHelm`), and no Reply-To. The footer names your install and its admin.
- Every link in the email goes to your install's own verified address (its CloudFront address or its CoderHelm name). An install on its own custom domain should use its own SES for now.
- It only sends to your install's people and pending invites, listed by an install admin, at most 50 new addresses a day, 30 emails a minute and 500 a day.
- An address that bounces or marks an email as spam gets nothing more. Too many bounces or complaints pause email for your install, and your install admins are told.

See [Threat model](./hybrid.md#email-threat-model) for what each of these protects against.
17 changes: 17 additions & 0 deletions docs/self-host/hybrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Your code, runs, plans, reviews, memory, knowledge and secrets stay in your AWS
| Token broker | the short-lived installation token it mints for your install (scoped to the repositories you chose, never more than the app's permissions) | no tokens; a record of each mint for 14 days |
| Jira app relay | each issue event, in transit, unchanged | as for GitHub. The Forge app's secret is checked by your install, so CoderHelm can't make an event up |
| Notion, Confluence, Google Drive | the sign-in, once | the provider sign-in, encrypted with a key only CoderHelm's services can use, so it can hand your install access tokens. Disconnecting revokes it. Notion's tokens don't expire by themselves: a copy your install holds stays valid until Notion's own integration page removes it |
| Email through CoderHelm (opt-in, [Email](./email.md#send-through-coderhelm)) | each email's recipient address, template id and parameters (names, PR titles and run links in the weekly summary), in transit; CoderHelm writes the email from its own templates | delivery metadata only: template id, a shortened address and the status, for 3 days. Salted hashes of the addresses your install listed, and your install admins' addresses sealed with a key only CoderHelm's services can use, to tell them if email pauses |
| Sharing with support (opt-in) | metadata of failed deliveries, and payload previews only if you also choose that | for 14 days, so support can see what failed |

CoderHelm never stores your code, never sees your model calls or your AWS credentials, and can't sign in to your install.
Expand All @@ -40,6 +41,7 @@ How the pieces are protected:
- **Scoped tokens.** The broker mints tokens only for installations linked to your install, narrowed to the repositories you chose and, within those, to the repositories the person who linked it can push to on GitHub. GitHub itself enforces both: they are part of the token request.
- **Sign-ins are yours only once your install takes them.** A Notion, Confluence or Google Drive sign-in is held apart until your install redeems it with its secret and its PKCE verifier, so nobody else can put their account in place of yours.
- **Revocable.** CoderHelm can turn an install's access off (its name and records go, its GitHub links are removed, the relay and broker refuse it, and the same CloudFront can't register again), and every action is in an audit log.
- **Email only as itself.** See [Email threat model](#email-threat-model) below.
- **Same-site safety.** Addresses under coderhelm.com are the same site as app.coderhelm.com and api.coderhelm.com to a browser, so CoderHelm doesn't rely on that: its cookies are host-only (`__Host-`, no Domain attribute), its CORS lists exact origins, and the API refuses any change sent with cookies from another page on the same site. An install's pages can't read or change coderhelm.com sessions.

The full threat model, with each attack and what stops it, is in [Security model](./security.md#hybrid-threat-model).
Expand Down Expand Up @@ -87,3 +89,18 @@ A forward that fails is retried with growing waits for about 24 hours. Both side
## For CoderHelm's operators

The hosted side runs in the hosted deployment's API stack when `hybrid.zone` is set in its config (the parent zone is configurable, so moving customer addresses to a separate domain later is a config change). It needs `hybrid_master_key` (32 or more random characters) in the hosted secret, the callback URL `https://api.coderhelm.com/auth/github/callback/hybrid` on CoderHelm's GitHub App, and the GitHub App's setup page (the dashboard's Settings, GitHub) to forward `state=hyb_…` returns. Platform admins see every install and the audit log at `GET /api/admin/hybrid`, and revoke one with `POST /api/admin/hybrid/:install_id/revoke`.


## Email threat model

What CoderHelm's mail service refuses, and how. Each line has a test (`services/common/src/mail`).

| Threat | What stops it |
|---|---|
| Another install, or someone without the install's secret, sends as your install | Every request is signed with the install's own secret (derived per install on CoderHelm's side), checked within 5 minutes, with a request id that is refused the second time. Only a registered, verified, not revoked install can send; revoking stops it at the next request. |
| An email made to look like it comes from CoderHelm support or security | No subject, HTML, sender or Reply-To can be sent: only a template id and parameters. Subjects are fixed. Parameters are plain text, escaped, length-limited, and refused when they read as CoderHelm itself ("CoderHelm support", "CoderHelm security"). The sender name is built only from the install's verified address, and a name that reads as CoderHelm staff (`support`, `billing`, `c0derhe1m` and other look-alikes) falls back to the CloudFront address. Every email's footer names the install. |
| A phishing link | Link parameters must be `https://` links to the install's own verified address. Links, addresses and look-alike domains in text parameters are removed before the email is written. |
| Mail to people outside the install | Only listed addresses: the install's admins, people and pending invites. Only an install admin can list an invite, at most 50 new addresses a day. CoderHelm's own addresses are never a recipient. |
| Spam or a burst | 30 emails a minute and 500 a day per install. Bounced and complaining addresses get nothing more; too many bounces or complaints pause the install's email and its admins are told. |
| Spoofing CoderHelm's sending domain | Mail comes from its own subdomain, `notify.coderhelm.com`, with Easy DKIM, SPF for a custom MAIL FROM and DMARC `p=reject`, so it can't harm the main domain's reputation and can't be forged from it. |
| Secrets in mail | Sign-up codes never leave the install. Parameters marked secret (signed approval and unsubscribe links) are never logged or stored; nothing is kept but delivery metadata. |
2 changes: 1 addition & 1 deletion docs/self-host/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Needs a domain (Google requires a fixed callback URL). Create an OAuth client in

## Weekly summary email

`integrations.weeklySummary` sends each team's members a Monday summary (13:00 UTC). People can turn it off in their notification settings or with the email's unsubscribe link.
The Monday summary (13:00 UTC) is an optional email: on a self-hosted install it is off until an install admin turns it on in **Settings, Emails**, no redeploy needed. `integrations.weeklySummary: true` in the config starts it on instead. Each person can still turn it off in their notification settings or with the email's unsubscribe link. See [Email](./email.md).

## Scheduled jobs

Expand Down
19 changes: 13 additions & 6 deletions docs/self-host/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ One list of everything you can set up, and where. Required items are steps in th
*Launch Stack:* `Hostname` (`HostedZone` to pick a zone)\
*Config:* `domain`\
*Checked by:* `domain`
- **Send email from**\
*Install guide:* More options\
*Launch Stack:* `EmailFrom`\
*Config:* `email.from`, `email.identity`\
*Checked by:* `email`, `email_identity`
- **Send email: your own Amazon SES or through CoderHelm**\
*Install guide:* More options, Send email\
*Launch Stack:* `EmailTransport`, `EmailFrom`\
*Config:* `email.transport`, `email.from`, `email.identity`\
*Checked by:* `email`, `email_identity`, `optional_emails`
- **Weekly summary email (off; turn on in Settings)**\
*Config:* `integrations.weeklySummary`\
*Checked by:* `optional_emails`
- **Let people from your company join** (default: only people you invite)\
*Install guide:* More options\
*Launch Stack:* `SignupDomain`\
Expand Down Expand Up @@ -85,6 +88,10 @@ One list of everything you can set up, and where. Required items are steps in th
- **Sign-up and password emails through SES**\
*Where:* `email.cognitoUsesSes`\
*Guide:* [Email](./email.md)
- **Optional emails (weekly summary, welcome) and how email is sent**\
*Where:* Settings, Emails\
*Checked by:* `optional_emails`\
*Guide:* [Email](./email.md)
- **Sign in with Google**\
*Where:* Google Cloud, the secret, `integrations.googleSignIn`\
*Checked by:* `google_sign_in`\
Expand Down Expand Up @@ -129,7 +136,7 @@ One list of everything you can set up, and where. Required items are steps in th
- **Keep data when stacks are deleted**\
*Where:* `retainData` (on)\
*Guide:* [Config reference](./config-reference.md)
- **The build sandbox, log analysis, weekly summary**\
- **The build sandbox, log analysis**\
*Where:* `integrations.*`\
*Guide:* [Integrations](./integrations.md)
- **Support access for install admins**\
Expand Down
9 changes: 8 additions & 1 deletion infra/cfn/coderhelm-selfhost-launch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Metadata:
- Label: { default: "Who may join (this install is for one organization; change these later in Settings, Sign-in)" }
Parameters: [SignupDomain, RequireTwoFactor]
- Label: { default: "Optional" }
Parameters: [EmailFrom, BedrockInferencePrefix, Telemetry]
Parameters: [EmailTransport, EmailFrom, BedrockInferencePrefix, Telemetry]
- Label: { default: "Optional: updates (you can change these later in Settings, System)" }
Parameters: [AutoUpdate, UpdateWindow, UpdateTimezone]
- Label: { default: "Filled in by the install guide (leave as they are)" }
Expand All @@ -36,6 +36,7 @@ Metadata:
Version: { default: "CoderHelm release" }
Hostname: { default: "Hostname" }
HostedZone: { default: "Route 53 hosted zone" }
EmailTransport: { default: "Send email" }
EmailFrom: { default: "Send email from" }
SignupDomain: { default: "Let people from your company join" }
RequireTwoFactor: { default: "Require two-factor sign-in" }
Expand Down Expand Up @@ -84,6 +85,11 @@ Parameters:
Default: ""
Description: Leave empty (the zone is found in this account). Only to pick one, e.g. example.com.
AllowedPattern: "^$|^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$"
EmailTransport:
Type: String
Default: ses
AllowedValues: [ses, coderhelm]
Description: "ses: through this account's Amazon SES (the default). coderhelm: through CoderHelm's mail service (hybrid; CoderHelm sees each recipient's address and the email's parameters, and keeps only delivery metadata)."
EmailFrom:
Type: String
Default: ""
Expand Down Expand Up @@ -210,6 +216,7 @@ Resources:
- { Name: STAGE, Value: !Ref Stage }
- { Name: ADMIN_EMAIL, Value: !Ref AdminEmail }
- { Name: EMAIL_FROM, Value: !Ref EmailFrom }
- { Name: EMAIL_TRANSPORT, Value: !Ref EmailTransport }
- { Name: HOSTNAME_ARG, Value: !Ref Hostname }
- { Name: HOSTED_ZONE, Value: !Ref HostedZone }
- { Name: MODEL_PROVIDER, Value: !Ref ModelProvider }
Expand Down
2 changes: 1 addition & 1 deletion infra/config/selfhost.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"googleSignIn": false,
"sandbox": true,
"logAnalyzer": true,
"weeklySummary": true
"weeklySummary": false
},
"telemetry": {
"enabled": false
Expand Down
16 changes: 13 additions & 3 deletions infra/lib/api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { Construct } from "constructs";
import { ResolvedConfig } from "./config";
import { repoPath } from "./paths";
import { Hybrid } from "./hybrid";
import { serviceEnvironment, modelPolicyStatements, publicUrlReadStatement, recordNameIn, setupEnvironment, setupStatements, updaterInvokeStatement } from "./service-env";
import { serviceEnvironment, modelPolicyStatements, publicUrlReadStatement, recordNameIn, setupEnvironment, setupStatements, updaterInvokeStatement, weeklySummaryScheduled } from "./service-env";
import { MailRelay, relaySendStatement } from "./mail-relay";

interface ApiStackProps extends cdk.StackProps {
stage: string;
Expand Down Expand Up @@ -49,6 +50,7 @@ export class ApiStack extends cdk.Stack {
public readonly gatewayFunction: lambda.Function;
public readonly mcpProxyFunction: lambda.Function;
public readonly ticketQueue: sqs.Queue;
/** The mail relay's bounces and complaints (hosted side of hybrid only). */
public readonly ciFixQueue: sqs.Queue;
public readonly feedbackQueue: sqs.Queue;
/** Outbound webhook events and their retries (common::webhooks). */
Expand Down Expand Up @@ -281,6 +283,12 @@ export class ApiStack extends cdk.Stack {
deadLetterQueue: { queue: dlq, maxReceiveCount: 3 },
});

// CoderHelm's mail relay (hosted side of hybrid only): its sending
// subdomain, DNS, configuration set, and bounces to the worker.
if (cfg.mailRelay) {
new MailRelay(this, "MailRelay", { cfg, ticketQueue: this.ticketQueue });
}

this.ciFixQueue = new sqs.Queue(this, "CiFixQueue", {
queueName: `${prefix}-ci-fix`,
visibilityTimeout: cdk.Duration.minutes(16),
Expand Down Expand Up @@ -393,7 +401,9 @@ export class ApiStack extends cdk.Stack {
new events.Rule(this, "WeeklySummarySchedule", {
ruleName: `${prefix}-weekly-summary`,
description: "Weekly summary email (Mondays 13:00 UTC)",
enabled: cfg.integrations.weeklySummary,
// Always there on a self-hosted install: the worker sends nothing
// until an install admin turns the summary on (Settings, Emails).
enabled: weeklySummaryScheduled(cfg),
schedule: events.Schedule.cron({ minute: "0", hour: "13", weekDay: "MON" }),
targets: [
new targets.SqsQueue(this.ticketQueue, {
Expand Down Expand Up @@ -559,7 +569,7 @@ export class ApiStack extends cdk.Stack {
...serviceEnvironment(cfg, this.account),
},
});
for (const st of [...modelPolicyStatements(cfg, this), publicUrlReadStatement(cfg, this), updaterInvokeStatement(cfg, this)]) {
for (const st of [...modelPolicyStatements(cfg, this), publicUrlReadStatement(cfg, this), updaterInvokeStatement(cfg, this), relaySendStatement(cfg, this.account)]) {
if (st) this.gatewayFunction.addToRolePolicy(st);
}
// A self-hosted install's GitHub App manifest landing (routes/setup.rs,
Expand Down
Loading
Loading