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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
with:
python-version: "3.12"
- run: python3 -m unittest discover -s lambda/tests
# The Cognito pre-sign-up trigger, against the cases the gateway uses.
- run: node --test lambda/pre-signup/handler.test.js

mcp-proxy:
name: MCP Proxy (Node)
Expand Down
8 changes: 5 additions & 3 deletions docs/self-host/config-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ See [Email](./email.md).
- **`admins`** *list of emails, required*\
Admins of the whole install: the admin pages (teams, the failed message queue, support). They may always sign up.
- **`signup.emails`** *list of emails, default `[]`*\
Others who may create an account.
First boot only: invited to the organization as members. After that, invite people in Settings, Team.
- **`signup.domains`** *list of domains, default `[]`*\
Anyone with an email at these domains may create an account.
First boot only: anyone with an email at these domains may join. After that, change them in Settings, Sign-in. Empty: only people the admins invite.
- **`signup.requireTwoFactor`** *boolean, default `false`*\
First boot only: start with two-factor sign-in required for everyone. After that, Settings, Sign-in.

Sign-up is closed to everyone else. People already on a team invite others from the dashboard.
A self-hosted install is one organization: sign-up is closed to everyone else. Admins invite people and allow email domains in the dashboard (see [Sign-in and people](./sign-in.md)).

## Integrations

Expand Down
6 changes: 5 additions & 1 deletion docs/self-host/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ One list of everything you can set up, and where. Required items are steps in th
*Launch Stack:* `EmailFrom`\
*Config:* `email.from`, `email.identity`\
*Checked by:* `email`, `email_identity`
- **Who else may sign up**\
- **Let people from your company join** (default: only people you invite)\
*Install guide:* More options\
*Launch Stack:* `SignupDomain`\
*Config:* `signup.domains`, `signup.emails`
- **Require two-factor sign-in**\
*Install guide:* More options\
*Launch Stack:* `RequireTwoFactor`\
*Config:* `signup.requireTwoFactor`
- **Automatic updates and the window**\
*Install guide:* More options\
*Launch Stack:* `AutoUpdate`, `UpdateWindow`, `UpdateTimezone`\
Expand Down
6 changes: 3 additions & 3 deletions docs/self-host/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ Your email: you@example.com
Emails come from [coderhelm@example.com]:
example.com is your Route 53 zone: the deploy adds its DKIM records and SES verifies it in minutes.
This account is in the SES sandbox: email only reaches verified addresses, 200 a day. ...
Let anyone with this email domain sign up (empty: only you) [example.com]:
This install is for one organization. Let people from your company join: an email domain such as example.com (empty: only people you invite) []:
```

You become the first admin. It checks the sender's SES identity (verified, with DKIM; when not, it prints the three DNS records to add) and whether the account is still in the SES sandbox (a warning, with the link to request production access). See [Email](./email.md).
You become the first admin. Nobody else can sign up unless you invite them or allow their email domain (change it later in **Settings, Sign-in**; see [Sign-in and people](./sign-in.md)). It checks the sender's SES identity (verified, with DKIM; when not, it prints the three DNS records to add) and whether the account is still in the SES sandbox (a warning, with the link to request production access). See [Email](./email.md).

## Step 6: optional extras

Expand Down Expand Up @@ -196,7 +196,7 @@ The [install guide](https://docs.coderhelm.com/self-host/install/) builds this l
- Quick-create link (replace both regions with yours):
`https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?stackName=coderhelm-prod&templateURL=https://coderhelm-public.s3.amazonaws.com/launch/v0.7.0/coderhelm-launch.yaml&param_AdminEmail=you@example.com`

Only your email is required. The optional parameters: `Hostname` (your own domain: a Route 53 zone in the account is found and set up for you, any other DNS provider gets two records to add, see [Domains](./domains.md)), `EmailFrom`, `SignupDomain`, `AutoUpdate` with `UpdateWindow` and `UpdateTimezone`, `BedrockInferencePrefix` and `Telemetry`. [Everything you can set up](./options.md) lists each with its config setting. Tick the box that lets the stack create IAM roles and press **Create stack**. A CodeBuild project in your account downloads the release, checks its signature and checksums, deploys every CoderHelm stack (about 20 minutes) and finishes with your URL in the stack's **Outputs**. Its log stays in CloudWatch under `/aws/codebuild/<stack name>-installer`, also if the stack is rolled back.
Only your email is required. The optional parameters: `Hostname` (your own domain: a Route 53 zone in the account is found and set up for you, any other DNS provider gets two records to add, see [Domains](./domains.md)), `EmailFrom`, `SignupDomain` (empty: only people you invite) and `RequireTwoFactor`, `AutoUpdate` with `UpdateWindow` and `UpdateTimezone`, `BedrockInferencePrefix` and `Telemetry`. [Everything you can set up](./options.md) lists each with its config setting. Tick the box that lets the stack create IAM roles and press **Create stack**. A CodeBuild project in your account downloads the release, checks its signature and checksums, deploys every CoderHelm stack (about 20 minutes) and finishes with your URL in the stack's **Outputs**. Its log stays in CloudWatch under `/aws/codebuild/<stack name>-installer`, also if the stack is rolled back.

Without the guide's setup key, create the GitHub App from your computer with the two commands in the **GitHubAppWithoutTheGuide** output (`pull`, then `github-app`).

Expand Down
83 changes: 67 additions & 16 deletions docs/self-host/sign-in.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,80 @@
---
title: Sign-in and people
description: Who may sign up, email and password with passkeys and two-factor codes, Google sign-in, GitHub accounts, install admins and team roles.
description: One organization per install, who may join (invites and allowed email domains), required two-factor sign-in, Google sign-in, GitHub accounts, install admins and team roles.
order: 6.5
---

Accounts live in a Cognito user pool in your AWS account. Nobody can sign up unless the config lets them.
Accounts live in a Cognito user pool in your AWS account. A self-hosted install is for **one organization**: one team, owned by the first admin. Nobody can make another team, and nobody can sign up on their own.

## Who may sign up
## Who may join

| Setting | Who | Where |
People join in one of two ways:

- **An invite.** An admin invites them by email in **Settings, Team**. The invite works for 30 days; resend it from **Pending invites**.
- **An allowed email domain.** Admins can let anyone with an email at a domain join, such as `example.com`, in **Settings, Sign-in**. They join as members. Public email services (Gmail, Outlook and the like) can't be allowed: that would let anyone in.

Everyone else is refused, on every way in: email sign-up, Google, GitHub, and the Cognito API itself. A pre-sign-up trigger in the user pool checks the same rules as CoderHelm, so even a direct Cognito `SignUp` call with the app's client id is refused.

The first admin is the address you gave the install (the Launch Stack's **Your email**, or `admins` in the config). Their first sign-in makes the organization; until then, only they can sign up.

### At install time

The install guide's **Let people from your company join** starts as **Only people I invite**. Pick **Anyone with an email at** and type your company's domain to allow it from the start. The config's `signup.domains` and `signup.emails` do the same: on first boot the domains become the allowed domains and the addresses become invites. After that, admins change both in **Settings** (the config is not read again).

| Setting | First boot | After |
|---|---|---|
| `admins` | The install's admins: they may always sign up, and see the admin pages (teams, failed events, support, Settings, then Setup and System) | The Launch Stack's **Your email**, or the config |
| `signup.domains` | Anyone with an email at these domains | The Launch Stack's **Who else may sign up** (one domain), or the config |
| `signup.emails` | These addresses | The config |
| Invites | Anyone a team admin invites | **Settings, People, Invite** (no config) |
| `admins` | The first admin (the first one to sign in makes the organization); the others are invited as admins | Install admins (see below) |
| `signup.domains` | Allowed email domains | **Settings, Sign-in** |
| `signup.emails` | Invited as members | **Settings, Team** |
| `signup.requireTwoFactor` | Two-factor sign-in required | **Settings, Sign-in** |

An install from before this change keeps working: its oldest team becomes the organization at the next sign-in, its config list is carried over as above, and people on other teams need an invite.

## Two-factor sign-in

Anyone can turn on two-factor sign-in for themselves in **Settings, Security**. Admins can require it for everyone: **Settings, Sign-in, Require two-factor sign-in**. Turn it on for yourself first; the switch asks for that, so you can't lock yourself out.

With it on:

- **Everyone** must set up an authenticator app (any TOTP app: 1Password, Google Authenticator, Authy and so on) before they can use CoderHelm. At their next sign-in they see a setup screen with a code to scan, and nothing else works until they enter a code from the app.
- **People who sign in with a password** use Cognito's own two-factor codes: Cognito asks for the code at every sign-in.
- **People who sign in with Google or GitHub** don't pass through Cognito's two-factor step, so CoderHelm asks for its own authenticator-app code right after Google or GitHub. Their secret is sealed with the install's KMS key. No sign-in path skips the code.
- **Sessions from before the switch** are checked at their next request: someone already signed in without a code is sent to the setup screen, or asked to sign in again with their code.
- **API keys** are not people and keep working. **Settings, Sign-in** lists them, so you can revoke any you don't want.

**Settings, Sign-in** shows who has set it up. If someone loses their phone, an admin can reset their two-factor sign-in after checking it's really them (a video call, say). The admin writes how they checked; the reset and the reason go in the log under **Settings, Roles**. The person sets it up again at their next sign-in. Only an owner can reset an admin's or another owner's. Nobody can reset their own.

### Wrong codes

Every place CoderHelm checks a code counts wrong ones against the person, by email, across every way in: the code after Google or GitHub, the code after a password, and turning the app code off.

- **Ten wrong codes in 15 minutes** pause that person's sign-in with a code for 15 minutes. Each pause after that is twice as long, up to a day. After a quiet day the count starts over. A right code clears the wrong ones so far.
- **One sign-in through Google or GitHub** allows five wrong codes; after that the person starts again from the sign-in screen.
- **The person** sees a plain sentence saying how long the pause lasts.
- **Admins** get an email, and a line in the log under **Settings, Roles**. If they lost their phone, check it's them and reset; if it wasn't them, someone may know their password or have their Google or GitHub account.

Cognito also limits wrong passwords on its own.

### Sessions that end

A person's existing sessions end, everywhere, when:

- an admin resets their two-factor sign-in;
- an admin removes them from the team;
- their role changes;
- they turn their own two-factor sign-in off (the session they did it from keeps working).

Every request checks the person's record, so the next request from an ended session goes back to the sign-in screen.

Sign-up is closed to everyone else. Change `signup` in the config and deploy, or invite people from the dashboard. The install guide's **Optional setup** list links to the invite page.
Why an authenticator app and not passkeys: Cognito's passkeys need its paid Essentials tier, a fixed sign-in domain (passkeys break when the CloudFront address changes to your own domain) and Cognito's hosted sign-in pages. Authenticator apps work on every install, including one on its free CloudFront address.

## Email and password, passkeys and two-factor codes
## Email and password

Always on. People confirm their email with a code, then can add a passkey or an authenticator app code in their own settings. Sign-up and password emails come from Amazon Cognito until `email.cognitoUsesSes` is on (see [Email](./email.md#sign-up-and-password-emails)); Cognito's own address is limited to 50 emails a day.
Always on. People confirm their email with a code. Sign-up and password emails come from Amazon Cognito until `email.cognitoUsesSes` is on (see [Email](./email.md#sign-up-and-password-emails)); Cognito's own address is limited to 50 emails a day.

## Sign in with Google

Optional, and it needs your own domain (Google requires a fixed sign-in address; see [Domains](./domains.md)).
Optional, and it needs your own domain (Google requires a fixed sign-in address; see [Domains](./domains.md)). It follows the same rules: only invited people and allowed domains.

1. In Google Cloud, **APIs and services, Credentials, Create credentials, OAuth client ID**, type **Web application**.
2. Add the authorized redirect URI `https://<sign-in domain>/oauth2/idpresponse` (the deploy's `SignInDomain` output shows the domain).
Expand All @@ -34,14 +85,14 @@ Settings, then Setup checks it (`google_sign_in`): off, on with its keys, or on

## GitHub accounts

People connect their GitHub account in their own settings, so pull requests and reviews are credited to them. It uses the GitHub App's own OAuth client, which the GitHub App step stores; nothing to set up.
People connect their GitHub account in their own settings, so pull requests and reviews are credited to them. Signing in with GitHub follows the same rules as everything else: it lands on the organization only for someone already in it, invited, or at an allowed domain (by the email on their GitHub account). It uses the GitHub App's own OAuth client, which the GitHub App step stores; nothing to set up.

## Single sign-on (SAML, OIDC)

Not available yet: CoderHelm's sign-in page offers email and password and Google. The Cognito user pool is in your account, so an identity provider added there by hand is not shown on the sign-in page and isn't supported.
Not available yet: CoderHelm's sign-in page offers email and password, Google and GitHub. The Cognito user pool is in your account, so an identity provider added there by hand is not shown on the sign-in page and isn't supported.

## Install admins and team roles

- **Install admins** (`admins`) see the whole install: every team, the failed events queue, support tickets, and the Setup and System pages. They must have an email CoderHelm verified itself.
- **Team roles** (viewer, member, admin, owner, and custom roles) are set per team in **Settings, People** and **Settings, Roles**.
- **Install admins** (`admins`) see the whole install: the failed events queue, support tickets, and the Setup and System pages. They must have an email CoderHelm verified itself.
- **Team roles** (viewer, member, admin, owner, and custom roles) are set in **Settings, Team** and **Settings, Roles**. Sign-in rules stay with built-in admins and owners; a custom role can't hold them.
- **Support access:** a team admin can let the install admins see the team's workspace read-only for a fixed time, with every read in the team's audit log (**Settings, Support access**).
17 changes: 14 additions & 3 deletions infra/cfn/coderhelm-selfhost-launch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ Metadata:
Parameters: [Stage, ModelProvider, Version]
- Label: { default: "Optional: your own domain (leave empty to use a free CloudFront address)" }
Parameters: [Hostname, HostedZone]
- 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, SignupDomain, BedrockInferencePrefix, Telemetry]
Parameters: [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 @@ -35,7 +37,8 @@ Metadata:
Hostname: { default: "Hostname" }
HostedZone: { default: "Route 53 hosted zone" }
EmailFrom: { default: "Send email from" }
SignupDomain: { default: "Who else may sign up" }
SignupDomain: { default: "Let people from your company join" }
RequireTwoFactor: { default: "Require two-factor sign-in" }
BedrockInferencePrefix: { default: "Bedrock inference profile" }
Telemetry: { default: "Anonymous install pings" }
AutoUpdate: { default: "Install new releases by themselves" }
Expand Down Expand Up @@ -89,8 +92,15 @@ Parameters:
SignupDomain:
Type: String
Default: ""
Description: Let anyone with an email at this domain sign up, e.g. example.com. Empty for only you (you can invite people later).
Description: >
Empty (the default) means only people you invite. Or an email domain, e.g. example.com: anyone with an email
there may join. This install is for one organization only; nobody else can sign up.
AllowedPattern: "^$|^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$"
RequireTwoFactor:
Type: String
Default: "off"
AllowedValues: ["off", "on"]
Description: on makes everyone set up an authenticator app before they can use CoderHelm, you included.
BedrockInferencePrefix:
Type: String
Default: auto
Expand Down Expand Up @@ -205,6 +215,7 @@ Resources:
- { Name: MODEL_PROVIDER, Value: !Ref ModelProvider }
- { Name: BEDROCK_PREFIX, Value: !Ref BedrockInferencePrefix }
- { Name: SIGNUP_DOMAIN, Value: !Ref SignupDomain }
- { Name: REQUIRE_TWO_FACTOR, Value: !Ref RequireTwoFactor }
- { Name: TELEMETRY, Value: !Ref Telemetry }
- { Name: AUTO_UPDATE, Value: !Ref AutoUpdate }
- { Name: UPDATE_WINDOW, Value: !Ref UpdateWindow }
Expand Down
26 changes: 26 additions & 0 deletions infra/lib/api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,32 @@ export class ApiStack extends cdk.Stack {
customMessageFn
);

// A self-hosted install is one organization: every account the user pool
// makes (sign-up with the app client, Google, AdminCreateUser) is checked
// against its rules first, so even a direct Cognito SignUp call is
// refused unless the person is invited, at an allowed domain, or the
// first admin. The gateway checks the same rules (routes/sign_in.rs).
if (cfg.layout === "single-origin") {
const preSignUpFn = new lambda.Function(this, "PreSignUpFn", {
functionName: `${prefix}-pre-signup`,
runtime: lambda.Runtime.NODEJS_22_X,
handler: "handler.handler",
code: lambda.Code.fromAsset(repoPath("lambda/pre-signup"), {
exclude: ["*.test.js", "cases.json"],
}),
timeout: cdk.Duration.seconds(5),
memorySize: 128,
environment: {
SETTINGS_TABLE_NAME: props.settingsTable.tableName,
USERS_TABLE_NAME: props.usersTable.tableName,
},
logRetention: logs.RetentionDays.ONE_MONTH,
});
props.settingsTable.grantReadData(preSignUpFn);
props.usersTable.grantReadData(preSignUpFn);
userPool.addTrigger(cognito.UserPoolOperation.PRE_SIGN_UP, preSignUpFn);
}

// Google identity provider (optional: integrations.googleSignIn).
// google_client_id and google_client_secret live in the deployment's
// secret (cfg.secretName). Callback URL:
Expand Down
Loading
Loading