Repository navigation
Description
Goal
Make a fresh public Orbit installation claimable only by the intended operator, while keeping the installation usable without Resend, Google OAuth, or GitHub OAuth.
This is a sibling of #391 and #392 under #388. It covers the safe first-owner, self-contained first-login, portable email, and production configuration work tracked by DEP-004, DEP-006, SEC-009, and part of CFG-001 in docs/open-source-readiness.md.
Current boundary
Several useful pieces already exist:
- Production build/startup refuses to proceed unless at least one login method is configured.
- Password authentication can be enabled with
ORBIT_PASSWORD_AUTH=trueand uses argon2id plus auth rate limits. - Google and GitHub OAuth are optional complete pairs.
- Email OTP and password-reset delivery currently use Resend only.
- Passkeys cannot bootstrap the first session.
ORBIT_DEV_LOGINis ignored in production.ALLOWED_EMAIL_DOMAINScontrols whether signup appears open, but an empty value means any email may sign up.- Any authenticated user may call the organization creation route;
createOrganizationgives that user an admin membership in the workspace it creates. - Onboarding creates a workspace and starter team after authentication.
That is sufficient for a manually watched deployment, but it is not a safe unattended one-click installation. A public URL can become reachable before the operator signs in, and the current configuration does not bind the initial owner to the person who installed the service.
Security model
A fresh instance has two distinct questions:
- Who may create the first account?
- Who may create additional accounts or workspaces after the first owner exists?
Do not conflate them. A one-time bootstrap secret is not a permanent signup policy, and a domain allowlist is not proof that the first visitor is the installer.
What to build
1. Explicit installation state
Define an installation-level state that can distinguish at least:
- unclaimed
- claimed
- bootstrap disabled or expired
The state must be durable in Postgres, not inferred from an in-memory flag or only from whether one user row happens to exist.
It must be safe under concurrent requests. Two first-account attempts racing each other must not both succeed. Use one transaction and a database constraint or lock that makes the claim single-use.
Do not infer “claimed” from any unrelated existing row such as a demo user, migration ledger, or partial failed signup.
2. Supported bootstrap modes
Support at least one noninteractive mode suitable for app stores and one operator-driven mode.
Recommended shapes:
Pre-authorized owner email
Only that normalized, verified email may complete the first account and become the installation owner. The value is not displayed publicly.
Single-use bootstrap token
A generator creates a high-entropy token outside the application container. The operator presents it once during first-account setup. Store only a keyed hash or equivalent verifier, never the raw token.
The token must:
- contain at least 128 bits of entropy
- expire or be explicitly invalidated
- be consumed atomically with the owner claim
- never appear in access logs, analytics, query strings, browser history, or error messages
- be rotatable before claim without rebuilding the image
A platform may expose both email and token and require both. Document the exact supported combinations rather than silently weakening to either/or.
3. First-owner creation
On successful claim:
- create or bind the authenticated user
- create the initial workspace through the canonical
packages/coreorganization service - assign the existing admin/owner-equivalent membership
- record claim time and claiming user in the installation state
- consume the bootstrap credential
- complete only the onboarding steps that were actually performed
- publish the same realtime actions as ordinary workspace creation
Do not write organization or membership rows directly from an auth callback.
If Orbit keeps admin as the highest stored role, document that clearly rather than introducing an unimplemented owner role only for marketing language.
4. Post-claim signup policy
Add an explicit production setting for account creation, with clear values such as:
ORBIT_SIGNUP_MODE=closed|invite|domain|open
Suggested behavior:
closed: no new account registration; existing users may sign ininvite: a valid unexpired Orbit invitation is requireddomain: email must match the configured allowlistopen: anyone may create an account
The default for the production Compose/app-store profile should not be open.
The server must enforce the mode in all account-creation paths, not only hide buttons:
- password signup
- email OTP creating a new user
- Google OAuth first login
- GitHub OAuth first login
- invitation acceptance
- account linking paths that could accidentally create a second identity
Changing the mode must not lock existing users out of sign-in.
5. Workspace creation policy
Separate account signup from workspace creation. A member invited into one workspace should not automatically gain permission to create unlimited independent workspaces on a single-tenant installation unless the operator selected that behavior.
Add a setting such as:
ORBIT_WORKSPACE_CREATION=admins|members|disabled
Define migration/default behavior for the existing hosted multi-workspace product so this self-hosting hardening does not silently change orbit.noveum.ai.
Enforce it server-side in POST /api/organizations or the canonical core boundary, not only in onboarding UI.
6. Portable email transport
Retain Resend and add a tested SMTP transport for self-hosted deployments.
Support a conventional configuration contract, for example:
SMTP_HOST=
SMTP_PORT=
SMTP_SECURE=
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_FROM=
Requirements:
- one deterministic transport-selection rule
- reject partially configured SMTP
- do not silently prefer one provider when both complete transports are set; require an explicit selection if ambiguity would be dangerous
- support local mail capture in development/CI
- preserve existing idempotency behavior as far as the transport permits
- bound connection, send, and response timeouts
- do not log credentials, OTPs, reset tokens, invitation tokens, or complete recipient lists
- return actionable operator errors while keeping user-facing responses resistant to account enumeration
Email remains optional when a complete password or social-login bootstrap path exists. Invitations and password resets should clearly report that email delivery is unavailable rather than failing silently.
7. Production configuration validation
Consolidate startup validation so the selected combination is checked as one installation contract.
Reject at least:
- placeholder or example
BETTER_AUTH_SECRET - secrets below the documented production entropy threshold
ORBIT_DEV_LOGINin production- localhost or non-HTTPS external URLs, except an explicit private-network development profile
- inconsistent
BETTER_AUTH_URLandNEXT_PUBLIC_APP_URL - incomplete OAuth provider pairs
- incomplete SMTP or Resend configuration
ORBIT_SIGNUP_MODE=domainwithout allowed domains- a bootstrap mode without its required email/token material
- an unclaimed public installation with no usable bootstrap path
- contradictory settings such as workspace creation enabled for users who cannot ever be created
Validation must run before accepting public traffic. A Docker health check should remain unready until the configuration is valid and the database can read the installation state.
8. Operator-facing status
Add a safe command or authenticated/admin-only status page that reports capabilities without printing secrets:
- installation claimed/unclaimed
- enabled sign-in methods
- signup mode
- workspace-creation policy
- email transport selected and whether a connection test succeeded
- external URL consistency
- bootstrap credential present/absent/expired, never its value
This can become part of the future doctor command in CFG-001.
Required tests
Claim race and credential handling
- Start from a database with an unclaimed installation state.
- Send two valid concurrent claim attempts and prove exactly one commits.
- Retry the consumed token and prove it fails.
- Attempt the claim with wrong email, wrong token, expired token, malformed token, and no credential.
- Prove no raw token appears in database rows, application logs, URLs, browser history, error payloads, or realtime events.
- Rotate an unused token and prove only the new one works.
- Restart every container during the unclaimed state and prove the claim contract survives.
Authentication matrix
Test fresh installations with:
- password-only bootstrap
- SMTP email OTP
- Resend email OTP
- complete Google OAuth
- complete GitHub OAuth
- intentionally incomplete configurations for each
For every successful mode, create the intended first owner and initial workspace. For every invalid mode, fail before public readiness.
Signup modes
For password, email OTP, Google, and GitHub first-login paths, prove:
closedrejects new usersinviteaccepts only a valid invitationdomainaccepts only allowed domainsopenaccepts an ordinary new user- existing users can still sign in under all modes
Workspace policy
Prove an ordinary member cannot create a workspace when policy is admins or disabled, and that an authorized user can when policy permits it. Cover both the onboarding surface and direct API calls.
- Send OTP, invitation, and password-reset mail through a local SMTP capture service.
- Prove Resend behavior remains covered.
- Simulate DNS, connection, authentication, timeout, provider rejection, and retry failures.
- Verify user-facing responses do not reveal whether an account exists.
- Verify logs and database delivery records contain no raw auth token or OTP.
Upgrade compatibility
Upgrade an existing hosted-style installation that predates the installation-state row. Define and test a safe deterministic migration:
- an installation with existing real users/workspaces must become claimed without exposing a new bootstrap window
- an empty fresh database must remain unclaimed
- demo/development fixtures must not influence production inference
Likely files
apps/web/src/lib/env.tsapps/web/src/lib/auth/server.tsapps/web/src/app/(auth)/login/apps/web/src/app/api/organizations/route.ts- onboarding routes and components
packages/core/src/org/organization-service.ts- new installation/bootstrap service under
packages/core packages/db/src/schema/auth.tsor a dedicated installation schemapackages/services/src/email/transports.ts- email transport tests
- production startup and copied-artifact smoke tests
docs/configuration.mddocs/self-hosting.mddocs/troubleshooting.mdSECURITY.md.env.example
Not part of this issue
- Portable WebSocket topology, tracked in Deployment: run realtime behind a provider-neutral same-origin WebSocket proxy #391
- Image and Compose construction, tracked in Deployment: publish production images and a complete Compose stack #392
- Full tenant lifecycle repair tracked by SEC-018
- Account-linking/recovery hardening tracked by SEC-013
- Invitation abuse limits tracked by SEC-002
- Credential-at-rest encryption tracked by SEC-015
Those security requirements remain release gates and must not be weakened by bootstrap shortcuts.
Review boundary
Split implementation into focused pull requests where practical:
- durable installation state, claim transaction, and signup/workspace policies
- SMTP transport and transport-selection validation
- consolidated production preflight, operator status, and production-shaped end-to-end matrix
Do not merge a partial first-owner flow that leaves another account-creation path open. The first release claim depends on the complete matrix above.
Activity