carlos / platform Public

console: declare server.go routes in routeDecls

The 164 registerRoute calls in NewServer become declarations in the new
routeDecls list (routedecls.go), each with the comment it had. NewServer
registers them through registerDecls where registerCLIRoutes was called,
after the db door state the old interleaved block set up; registration
reads none of that state. The scanners read the new list in a later
commit and are red until then.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 6ba8172e9c44dcfeb9de35b5a5b7589c649027b8 parent 3d226e3
2 files changed, +443 −315
  • internal/console/routedecls.go +436 −0
  • internal/console/server.go +7 −315

Intent

Attributed to this commit: 1.37 g CO₂e (181,810 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-parity-guard, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go
new file mode 100644
index 000000000..e172662dd
--- /dev/null
+++ b/internal/console/routedecls.go
@@ -0,0 +1,436 @@
+package console
+
+import (
+ "fmt"
+ "net/http"
+
+ "github.com/carlosframework/platform/internal/svcrole"
+ "github.com/carlosframework/platform/internal/version"
+)
+
+// routeKind picks the helper a declaration is registered through, and so
+// the wrapper its handler runs behind.
+type routeKind uint8
+
+const (
+ // kindPlain is registerRoute alone: no role gate. Never an /api/cli/
+ // door (TestAuthCLIFamilyResolvesOnlyPersons, the bypass scan).
+ kindPlain routeKind = iota
+ // kindCLI is cliRoute: the bearer resolved once and the role gate.
+ kindCLI
+ // kindCLIJournaled is cliRouteJournaled: cliRoute whose refusals are
+ // also told to Refused.
+ kindCLIJournaled
+ // kindCLIScoped is cliScopedRoute: the team role admitted, with the
+ // scope step for Target before the handler.
+ kindCLIScoped
+)
+
+// isCLI reports whether the kind is one of the /api/cli/ door kinds.
+func (k routeKind) isCLI() bool { return k != kindPlain }
+
+// routeGate is a named predicate over Config. A declaration with a gate is
+// registered only when the gate holds for the console's configuration at
+// the moment registerDecls runs.
+type routeGate struct {
+ name string
+ holds func(Config) bool
+}
+
+var (
+ gateDemo = &routeGate{"demo", func(c Config) bool { return c.Demo.Enabled || c.Demo.BoxMode() }}
+ gateHostClaim = &routeGate{"host-claim", func(c Config) bool { return c.HostClaim }}
+ gateNoHostClaim = &routeGate{"no-host-claim", func(c Config) bool { return !c.HostClaim }}
+ gateRegionHA = &routeGate{"region-ha", func(c Config) bool { return c.HostClaim && c.RegionHA }}
+ gateMoves = &routeGate{"moves", func(c Config) bool { return c.MovesEnabled }}
+)
+
+// routeGates is every gate a declaration may carry. The equality test
+// (TestRouteDeclsMatchRegistrations) flips each one on and off.
+var routeGates = []*routeGate{gateDemo, gateHostClaim, gateNoHostClaim, gateRegionHA, gateMoves}
+
+// routeDecl is one console route: everything its registration needs.
+type routeDecl struct {
+ // Pattern is the mux pattern exactly as registered, method first when
+ // it has one ("GET /a/{sqid}/apps/{app}", or methodless
+ // "/fleet/architecture").
+ Pattern string
+ Kind routeKind
+ // Gate is nil for a route every console registers.
+ Gate *routeGate
+ // Allow is the role set of a cli kind. The zero Set admits no
+ // service credential.
+ Allow svcrole.Set
+ // Target is the scope step of a kindCLIScoped door.
+ Target scopeTarget
+ // Refused is a kindCLIJournaled door's refusal hook, a method
+ // expression.
+ Refused func(*Server, *http.Request, Principal, int)
+ // Handler is a method expression, e.g. (*Server).handleHome. Exactly
+ // one of Handler and Build is set.
+ Handler func(*Server, http.ResponseWriter, *http.Request)
+ // Build returns the handler for one that closes over state. A plain
+ // declaration's Build returns a function literal, so the person-only
+ // scan can read its body.
+ Build func(*Server) http.HandlerFunc
+}
+
+// routeDecls is every route the console registers. NewServer registers
+// from it through registerDecls, and nothing else in the package touches
+// the mux (TestClaimConsoleMuxHasOneRegistrar).
+var routeDecls = []routeDecl{
+ // The browser console, its sign-in and the unauthenticated doors
+ // (server.go): pages, forms, webhooks and the box doors.
+ {Pattern: "GET /{$}", Handler: (*Server).handleHome},
+ {Pattern: "GET /static/{hash}/{file...}", Handler: (*Server).handleStatic},
+ {Pattern: "POST /auth/continue", Handler: (*Server).handleContinue},
+ {Pattern: "GET /auth/email/link", Handler: (*Server).handleEmailLinkPage},
+ {Pattern: "POST /auth/email/link", Handler: (*Server).handleEmailLink},
+ {Pattern: "POST /auth/email/code", Handler: (*Server).handleEmailCode},
+ {Pattern: "POST /auth/email/stepup/code", Handler: (*Server).handleStepUpEmailCode},
+ {Pattern: "GET /auth/signin", Handler: (*Server).handleSignin},
+ {Pattern: "GET /auth/callback", Handler: (*Server).handleCallback},
+ // Passkey step-up (stepup.go): where a re-authentication lands, on its own
+ // route so a step-up code and a sign-in code are never interchangeable.
+ {Pattern: "GET /auth/stepup/callback", Handler: (*Server).handleStepUpCallback},
+ {Pattern: "GET /auth/confirm", Handler: (*Server).handleConfirm},
+ {Pattern: "POST /auth/signout", Handler: (*Server).handleSignout},
+ {Pattern: "GET /fleet", Handler: (*Server).handleDashboard},
+ {Pattern: "GET /fleet/activity", Handler: (*Server).handleActivity},
+ {Pattern: "GET /fleet/boxes", Handler: (*Server).handleBoxes},
+ {Pattern: "GET /fleet/index", Handler: (*Server).handleOpIndex},
+ {Pattern: "GET /fleet/people", Handler: (*Server).handlePeople},
+ {Pattern: "GET /fleet/people/{address}", Handler: (*Server).handlePerson},
+ {Pattern: "GET /fleet/store", Handler: (*Server).handleStoreApprovalsPage},
+ {Pattern: "POST /fleet/store/{account}/{decision}", Handler: (*Server).handleStoreDecisionPage},
+ {Pattern: "POST /a/{sqid}/store/apply", Handler: (*Server).handleStoreApplyPage},
+ {Pattern: "GET /fleet/metrics", Handler: (*Server).handleFleetMetrics},
+ // Fleet alerts (alertpages.go): the operator pages, same gate. Their
+ // writes are registered without a method, as the economics doors below
+ // are and for the same reason: a wrong method answers the unknown
+ // route's 404, never a 405 that says the door is there.
+ {Pattern: "GET /fleet/alerts", Handler: (*Server).handleFleetAlerts},
+ {Pattern: "GET /fleet/alerts/history", Handler: (*Server).handleFleetAlertHistory},
+ {Pattern: "/fleet/alerts/connectors", Handler: (*Server).handleAlertConnectorAdd},
+ {Pattern: "/fleet/alerts/connectors/{id}/test", Handler: (*Server).handleAlertConnectorTest},
+ {Pattern: "/fleet/alerts/connectors/{id}/confirm-link", Handler: (*Server).handleAlertConnectorConfirmLink},
+ {Pattern: "/fleet/alerts/connectors/{id}/delete", Handler: (*Server).handleAlertConnectorDelete},
+ {Pattern: "/fleet/alerts/rules/{rule}", Handler: (*Server).handleAlertRuleSave},
+ // The links alert messages carry, public: the token is the credential.
+ // Each GET shows a page and acts on nothing; only the POST acts, so a
+ // scanner that opens every link in a mail changes nothing.
+ {Pattern: "GET /alerts/confirm/{token}", Handler: (*Server).handleAlertConfirmPage},
+ {Pattern: "POST /alerts/confirm/{token}", Handler: (*Server).handleAlertConfirm},
+ {Pattern: "GET /alerts/unsubscribe/{token}", Handler: (*Server).handleAlertUnsubscribePage},
+ {Pattern: "POST /alerts/unsubscribe/{token}", Handler: (*Server).handleAlertUnsubscribe},
+ {Pattern: "GET /alerts/snooze/{token}", Handler: (*Server).handleAlertSnoozePage},
+ {Pattern: "POST /alerts/snooze/{token}", Handler: (*Server).handleAlertSnooze},
+ {Pattern: "GET /alerts/signing-key", Handler: (*Server).handleAlertSigningKey},
+ {Pattern: "GET /fleet/economics", Handler: (*Server).handleEconomics},
+ // The operator's Protection page (protectionview.go) and its JSON door:
+ // what the edge guard did across every app. Operators only, as Economics.
+ {Pattern: "GET /fleet/protection", Handler: (*Server).handleFleetProtection},
+ {Pattern: "GET /fleet/protection/data", Handler: (*Server).handleFleetProtectionData},
+ // The deployment's map (archpage.go), same operatorOnly gate. BOTH are
+ // registered WITHOUT a method prefix, for the reason spelled out below
+ // the economics doors: a "GET /path" pattern answers a POST with 405 +
+ // Allow, which distinguishes this route from an unrouted one to anyone
+ // who merely guessed the URL — the exact probe the gate exists to
+ // prevent. Each handler checks r.Method itself, first thing.
+ {Pattern: "/fleet/architecture", Handler: (*Server).handleArchitecture},
+ {Pattern: "/fleet/architecture/refresh", Handler: (*Server).handleArchitectureRefresh},
+ // Per-account table (Task 14): same gate, its own search/filter/cursor
+ // controls (econlistquery.go) over the same LoadEconomics rows.
+ {Pattern: "GET /fleet/economics/accounts", Handler: (*Server).handleEconomicsAccounts},
+ // Unit economics (Task 12): scenario/bill writes, operator-only, same
+ // gate shape as handleDashboard above. GET /fleet/economics is handled
+ // above by handleEconomics (Task 13). Registered WITHOUT a method
+ // prefix, deliberately: a
+ // "POST /path" pattern answers a GET with 405 + Allow, which leaks that
+ // the route exists to someone who merely guessed the URL — the exact
+ // probe operatorOnly's 404-to-everyone gate exists to prevent. Each
+ // handler below checks r.Method itself, before anything else, so a
+ // wrong-method request is byte-identical to an unknown route.
+ {Pattern: "/fleet/economics/scenarios", Handler: (*Server).handleEconomicsScenarioSave},
+ {Pattern: "/fleet/economics/bill", Handler: (*Server).handleEconomicsBillSave},
+ {Pattern: "/api/economics/bill", Handler: (*Server).handleAPIEconomicsBill},
+ {Pattern: "/api/economics/backhaul", Handler: (*Server).handleAPIEconomicsBackhaul},
+ // Account tier (economics-v2, Task 4): same bare-registration/method-
+ // first reasoning as the two doors above.
+ {Pattern: "/fleet/economics/tier", Handler: (*Server).handleEconomicsTierSave},
+ // Account-scoped and explicit: /a/<sqid>/apps/<app> rather than
+ // account-by-session, so a link a teammate opens lands where you meant.
+ {Pattern: "GET /a/{sqid}/{$}", Handler: (*Server).handleAccountHome},
+ {Pattern: "GET /a/{sqid}/index", Handler: (*Server).handleAccountIndex},
+ {Pattern: "GET /a/{sqid}/fleet", Handler: (*Server).handleAccountFleetTab},
+ {Pattern: "GET /a/{sqid}/fleet/byo", Handler: (*Server).handleFleetBYO},
+ {Pattern: "GET /a/{sqid}/team", Handler: (*Server).handleTeam},
+ {Pattern: "GET /a/{sqid}/settings", Handler: (*Server).handleAccountSettings},
+ {Pattern: "POST /a/{sqid}/errors/level", Handler: (*Server).handleAccountErrorLevel},
+ {Pattern: "POST /a/{sqid}/analytics/setting", Handler: (*Server).handleAccountAnalyticsSetting},
+ // Plans 4d: owners choose what stays after a lapse (planlapse_keep.go).
+ {Pattern: "GET /a/{sqid}/plan/keep", Handler: (*Server).handlePlanKeep},
+ {Pattern: "POST /a/{sqid}/plan/keep", Handler: (*Server).handlePlanKeepSave},
+ // Plans 6b: an owner's Confirm now finishes a billing operation left
+ // without a definite outcome (billingops.go). 404 with billing off.
+ {Pattern: "POST /a/{sqid}/billing/confirm", Handler: (*Server).handleBillingConfirm},
+ // Plans 6b: Checkout (billingcheckout.go). The owner's buy and Start over
+ // POST, Continue back to an open payment page, and the return from it.
+ // 404 with billing off.
+ {Pattern: "POST /a/{sqid}/billing/checkout", Handler: (*Server).handleBillingCheckout},
+ {Pattern: "GET /a/{sqid}/billing/continue", Handler: (*Server).handleBillingContinue},
+ {Pattern: "GET /a/{sqid}/billing/done", Handler: (*Server).handleBillingDone},
+ // Plans 6b: an owner's pack change or plan upgrade, and stopping or
+ // resuming renewal (billingchange.go). 404 with billing off.
+ {Pattern: "POST /a/{sqid}/billing/change", Handler: (*Server).handleBillingChange},
+ {Pattern: "POST /a/{sqid}/billing/renewal", Handler: (*Server).handleBillingRenewal},
+ // Plans 6b: an owner's Match seats to members (billingseats.go). 404
+ // with billing off.
+ {Pattern: "POST /a/{sqid}/billing/seats", Handler: (*Server).handleBillingSeats},
+ // Plans 6b: an owner's way to the provider's locked portal for cards
+ // and invoices (billingportal.go). 404 with billing off.
+ {Pattern: "POST /a/{sqid}/billing/portal", Handler: (*Server).handleBillingPortal},
+ {Pattern: "POST /a/{sqid}/billing/card", Handler: (*Server).handleBillingCard},
+ // The billing page (billingpage.go): member-readable, its forms the
+ // owner's. 404 with billing off.
+ {Pattern: "GET /a/{sqid}/billing", Handler: (*Server).handleBilling},
+ // Go 1.22's mux prefers this literal over apps/{app} below — exactly why
+ // "new" must be a reserved app name (claimApp): an app so named could
+ // never be viewed.
+ {Pattern: "GET /a/{sqid}/apps/new", Handler: (*Server).handleNewAppForm},
+ {Pattern: "POST /a/{sqid}/apps/new", Handler: (*Server).handleNewApp},
+ {Pattern: "POST /a/{sqid}/apps/new/region", Handler: (*Server).handleNewAppRegion},
+ {Pattern: "GET /a/{sqid}/apps/{app}/source", Handler: (*Server).handleBrowserAppSource},
+ {Pattern: "GET /a/{sqid}/apps/{app}", Handler: (*Server).handleApp},
+ {Pattern: "GET /a/{sqid}/apps/{app}/index", Handler: (*Server).handleAppIndex},
+ {Pattern: "GET /a/{sqid}/apps/{app}/releases", Handler: (*Server).handleAppReleases},
+ // The retired Deployments tab: Live now on the Releases page took its
+ // table. accountApp's gates run before the 303.
+ {Pattern: "GET /a/{sqid}/apps/{app}/deployments", Handler: (*Server).handleAppDeploymentsRedirect},
+ {Pattern: "GET /a/{sqid}/apps/{app}/account-review", Handler: (*Server).handleAppAccountReview},
+ {Pattern: "GET /a/{sqid}/apps/{app}/instances", Handler: (*Server).handleAppInstances},
+ {Pattern: "GET /a/{sqid}/apps/{app}/instances/{host}", Handler: (*Server).handleAppInstance},
+ {Pattern: "POST /a/{sqid}/apps/{app}/restart", Handler: (*Server).handleAppRestart},
+ {Pattern: "POST /a/{sqid}/apps/{app}/instances/{host}/restart", Handler: (*Server).handleInstanceRestart},
+ {Pattern: "POST /a/{sqid}/apps/{app}/instances/{host}/retry", Handler: (*Server).handleInstanceRetry},
+ {Pattern: "POST /a/{sqid}/apps/{app}/instances/{host}/updates", Handler: (*Server).handleBrowserUpdates},
+ {Pattern: "POST /a/{sqid}/apps/{app}/instances/{host}/updates/install", Handler: (*Server).handleBrowserUpdateNow},
+ {Pattern: "GET /a/{sqid}/apps/{app}/logs", Handler: (*Server).handleAppLogs},
+ {Pattern: "GET /a/{sqid}/apps/{app}/logs/data", Handler: (*Server).handleAppLogsData},
+ // The Errors tab and its two setting doors (errorsview.go): the tab is
+ // member-readable like every other app tab; the level is the owner's,
+ // at app and account level, and both POSTs go through the console gate
+ // (CSRF, then owner, then the byte-identical 404).
+ {Pattern: "GET /a/{sqid}/apps/{app}/errors", Handler: (*Server).handleAppErrors},
+ {Pattern: "POST /a/{sqid}/apps/{app}/errors/level", Handler: (*Server).handleAppErrorLevel},
+ // Availability (errorsview.go): the Errors tab's sibling for the
+ // failures that are the instance's, not the request's — edge 502/503/504
+ // by cause and the platform's lifecycle events. Member-readable, no
+ // setting of its own.
+ {Pattern: "GET /a/{sqid}/apps/{app}/availability", Handler: (*Server).handleAppAvailability},
+ // The Analytics tab (analyticsview.go) and the switch beside it. The tab
+ // is member-readable like every other app tab; the switch rides the same
+ // gate the errors level does at both levels, and bumps the serial where
+ // the errors level does not: a box acts on whether the edge counts.
+ {Pattern: "GET /a/{sqid}/apps/{app}/analytics", Handler: (*Server).handleAppAnalytics},
+ {Pattern: "GET /a/{sqid}/apps/{app}/analytics/live", Handler: (*Server).handleAnalyticsLive},
+ {Pattern: "POST /a/{sqid}/apps/{app}/analytics/setting", Handler: (*Server).handleAppAnalyticsSetting},
+ // The Protection tab (protectionview.go) and its JSON door: what the
+ // edge guard checked, recorded and blocked for the app. Member-readable
+ // like the Analytics tab, through the same gate.
+ {Pattern: "GET /a/{sqid}/apps/{app}/protection", Handler: (*Server).handleAppProtection},
+ {Pattern: "GET /a/{sqid}/apps/{app}/protection/data", Handler: (*Server).handleAppProtectionData},
+ {Pattern: "POST /a/{sqid}/apps/{app}/protection/setting", Handler: (*Server).handleAppProtectionSetting},
+ {Pattern: "GET /a/{sqid}/apps/{app}/activity", Handler: (*Server).handleAppActivity},
+ {Pattern: "GET /a/{sqid}/apps/{app}/settings", Handler: (*Server).handleAppSettings},
+ {Pattern: "GET /a/{sqid}/apps/{app}/settings/{section}", Handler: (*Server).handleAppSettings},
+ {Pattern: "GET /a/{sqid}/apps/{app}/settings/index", Handler: (*Server).handleAppSettingsIndex},
+ // The Environments section's one form (envform.go): any member, CSRF;
+ // staging re-renders, Save writes one bundle.
+ {Pattern: "POST /a/{sqid}/apps/{app}/settings/environments", Handler: (*Server).handleEnvForm},
+ // The pipeline settings page (pipelinepage.go, release pipelines v2 §5)
+ // is the Settings tab's Release pipeline section; the old GET answers
+ // with a 303 to it, after accountApp's gates. POST goes through the same
+ // guarded path the API PUT does, and keeps this path.
+ {Pattern: "GET /a/{sqid}/apps/{app}/pipeline", Handler: (*Server).handleAppPipelineRedirect},
+ {Pattern: "POST /a/{sqid}/apps/{app}/pipeline", Handler: (*Server).handlePipelineSettingsSave},
+ {Pattern: "POST /a/{sqid}/apps/{app}/promote", Handler: (*Server).handlePromote},
+ {Pattern: "POST /a/{sqid}/apps/{app}/rollback", Handler: (*Server).handleRollback},
+ {Pattern: "POST /a/{sqid}/apps/{app}/production", Handler: (*Server).handleProduction},
+ {Pattern: "POST /a/{sqid}/apps/{app}/fasttrack", Handler: (*Server).handleFastTrack},
+ // The pending-change doors (pendinghandlers.go, release pipelines v2 §4):
+ // confirm is member-gated with the passkey step-up LAST, reject is the
+ // proposer's or an owner's and deliberately carries no step-up — refusing
+ // authority is not exercising it.
+ {Pattern: "POST /a/{sqid}/apps/{app}/pending/{id}/confirm", Handler: (*Server).handlePendingConfirm},
+ {Pattern: "POST /a/{sqid}/apps/{app}/pending/{id}/reject", Handler: (*Server).handlePendingReject},
+ {Pattern: "POST /a/{sqid}/apps/{app}/canary", Handler: (*Server).handleNewCanary},
+ {Pattern: "POST /a/{sqid}/apps/{app}/canary/retire", Handler: (*Server).handleRetireCanary},
+ // The app Settings writes (appsettings.go): owner-only, and delete/move
+ // behind passkey step-up besides.
+ {Pattern: "POST /a/{sqid}/apps/{app}/place", Handler: (*Server).handleAppPlace},
+ // The password-gate form (appsettings.go's handleAppGate): member-gated,
+ // unlike the owner-only writes above it.
+ {Pattern: "POST /a/{sqid}/apps/{app}/gate", Handler: (*Server).handleAppGate},
+ // The rate-limit form beside it (handleAppRateLimit): member-gated too.
+ {Pattern: "POST /a/{sqid}/apps/{app}/ratelimit", Handler: (*Server).handleAppRateLimit},
+ // The Deploys card's form (appswap.go): member-gated, like the gate.
+ {Pattern: "POST /a/{sqid}/apps/{app}/swap", Handler: (*Server).handleAppSwap},
+ {Pattern: "POST /a/{sqid}/apps/{app}/rename", Handler: (*Server).handleAppRename},
+ {Pattern: "POST /a/{sqid}/apps/{app}/region", Handler: (*Server).handleAppRegionSet},
+ {Pattern: "POST /a/{sqid}/apps/{app}/keep", Handler: (*Server).handleAppKeep},
+ // The app list's star (any member, the viewer's own) and Extend form
+ // (owners) (applist.go).
+ {Pattern: "POST /a/{sqid}/apps/{app}/star", Handler: (*Server).handleAppStar},
+ {Pattern: "POST /a/{sqid}/apps/{app}/extend", Handler: (*Server).handleAppExtend},
+ // The Getting started card's preferences (any member, the viewer's own)
+ // (gettingstarted_handlers.go).
+ {Pattern: "POST /a/{sqid}/getting-started/hide", Handler: (*Server).handleGettingStartedHide},
+ {Pattern: "POST /a/{sqid}/getting-started/show", Handler: (*Server).handleGettingStartedShow},
+ {Pattern: "POST /a/{sqid}/getting-started/skip", Handler: (*Server).handleGettingStartedSkip},
+ {Pattern: "POST /a/{sqid}/getting-started/done", Handler: (*Server).handleGettingStartedDone},
+ {Pattern: "POST /a/{sqid}/apps/{app}/delete", Handler: (*Server).handleAppDelete},
+ {Pattern: "POST /a/{sqid}/apps/{app}/move", Handler: (*Server).handleAppMoveAccount},
+ // The control-plane flag's two directions, both browser-only and both
+ // owner-only. Clearing is passkey-gated, setting is not — the asymmetry
+ // is spec §6's, and there is deliberately no API sibling for either
+ // (controlplane.go).
+ {Pattern: "POST /a/{sqid}/apps/{app}/control-plane/clear", Handler: (*Server).handleAppControlPlaneClear},
+ {Pattern: "POST /a/{sqid}/apps/{app}/control-plane/set", Handler: (*Server).handleAppControlPlaneSet},
+ // Domain purchases: owner sessions, with CSRF on both form posts.
+ {Pattern: "GET /a/{sqid}/apps/{app}/domains/buy", Handler: (*Server).handleAppDomainBuyForm},
+ {Pattern: "POST /a/{sqid}/apps/{app}/domains/check", Handler: (*Server).handleAppDomainBuyCheck},
+ {Pattern: "POST /a/{sqid}/apps/{app}/domains/buy", Handler: (*Server).handleAppDomainBuy},
+ {Pattern: "GET /a/{sqid}/apps/{app}/domains/purchases/{id}", Handler: (*Server).handleAppDomainPurchase},
+ {Pattern: "GET /a/{sqid}/apps/{app}/domains/purchases/{id}/status", Handler: (*Server).handleAppDomainPurchaseStatus},
+ // Custom domain attach/detach (appdomains.go, #82): owner-only, no
+ // passkey step-up (spec §6) — detach's guard is the typed-host confirm.
+ {Pattern: "POST /a/{sqid}/apps/{app}/domains/attach", Handler: (*Server).handleAppDomainAttach},
+ {Pattern: "POST /a/{sqid}/apps/{app}/domains/detach", Handler: (*Server).handleAppDomainDetach},
+
+ // Customer fleets (Task 9): the owner's own remote boxes and what's
+ // placed on them — member-readable, owner-gated for rotate/detach
+ // (fleets.go).
+ {Pattern: "GET /a/{sqid}/fleets/{fleet}", Handler: (*Server).handleFleetPage},
+ {Pattern: "POST /a/{sqid}/fleets/{fleet}/rotate", Handler: (*Server).handleFleetRotateBoxPage},
+ {Pattern: "POST /a/{sqid}/fleets/{fleet}/detach", Handler: (*Server).handleFleetDetachBoxPage},
+ {Pattern: "POST /a/{sqid}/fleets/{fleet}/tags", Handler: (*Server).handleFleetTagBoxPage},
+ {Pattern: "POST /a/{sqid}/fleets/{fleet}/place", Handler: (*Server).handleFleetPlacePage},
+ // The object store's destroy door (appsettings.go, issue #55): the account
+ // owner, the bucket name typed out, and a passkey. It is the only console
+ // route that destroys a customer's objects outside the app trash, and
+ // unlike the trash there is no cooloff behind it.
+ {Pattern: "POST /a/{sqid}/apps/{app}/store/destroy", Handler: (*Server).handleStoreDestroy},
+ {Pattern: "POST /a/{sqid}/invite", Handler: (*Server).handleInvite},
+ {Pattern: "POST /a/{sqid}/invite/revoke", Handler: (*Server).handleRevokeInvite},
+ // Owner-only account administration, every one of them behind passkey
+ // step-up as well as ownership and CSRF (ownership.go, spec §7a).
+ {Pattern: "POST /a/{sqid}/members/remove", Handler: (*Server).handleRemoveMember},
+ {Pattern: "POST /a/{sqid}/members/transfer", Handler: (*Server).handleTransferOwnership},
+ {Pattern: "POST /a/{sqid}/delete", Handler: (*Server).handleDeleteAccount},
+ // The service-credential pane's writes (svcpage.go, issue #220):
+ // owner-only, and create/rotate behind passkey step-up besides. Revoke
+ // deliberately is NOT — it is the emergency control, and it must not sit
+ // behind a round trip that fails closed. See svcpage.go's doc comment.
+ {Pattern: "POST /a/{sqid}/services/new", Handler: (*Server).handleServiceCreatePage},
+ {Pattern: "POST /a/{sqid}/services/rotate", Handler: (*Server).handleServiceRotatePage},
+ {Pattern: "POST /a/{sqid}/services/revoke", Handler: (*Server).handleServiceRevokePage},
+ {Pattern: "GET /a/{sqid}/trash", Handler: (*Server).handleTrash},
+ {Pattern: "POST /a/{sqid}/trash/restore", Handler: (*Server).handleRestoreApp},
+ {Pattern: "POST /a/{sqid}/trash/delete", Handler: (*Server).handlePurgeApp},
+ // GET only shows the invitation; joining is the POST its button sends
+ // (discussion #219, item 4).
+ {Pattern: "GET /invite/{token}", Handler: (*Server).handleInvitePage},
+ {Pattern: "POST /invite/{token}", Handler: (*Server).handleAcceptInvite},
+ {Pattern: "GET /accounts", Handler: (*Server).handleAccountsIndex},
+ {Pattern: "GET /accounts/new", Handler: (*Server).handleNewAccountForm},
+ // The upgrade entry the public pricing page links to (billingpage.go,
+ // plans 6b Call 1): signed out, the front door with next; signed in,
+ // the billing page of the account the viewer owns. 404 with billing off.
+ {Pattern: "GET /upgrade", Handler: (*Server).handleUpgrade},
+ {Pattern: "POST /accounts/new", Handler: (*Server).handleNewAccount},
+ // The pre-accounts URLs, kept as redirects so old links and bookmarks
+ // still land somewhere sensible rather than 404ing.
+ {Pattern: "GET /apps", Handler: (*Server).handleLegacyApps},
+ {Pattern: "GET /apps/{app}", Handler: (*Server).handleLegacyApp},
+ // "ok <build>" — the build comes from THIS PROCESS (ldflags, at link
+ // time), which is the whole point: X-Carlos-Version is stamped by the
+ // edge from the route row, so it reports the version adoption INTENDED
+ // from the moment the symlink moves, whether or not anything restarted.
+ // `carlos deploy` polls this instead for any app declaring a build probe.
+ //
+ // "ok" stays the first token: internal/vet and the edge health probe read
+ // this endpoint and check status, not body, but keeping the prefix means
+ // a human or a script eyeballing it sees what it always saw.
+ {Pattern: "GET /healthz", Build: func(s *Server) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprintln(w, "ok", version.Build)
+ }
+ }},
+ // SES event ingest (sesevents.go, tenant-email spec §9): UNAUTHENTICATED,
+ // like healthz above — SNS is not a signed-in member, so there is no
+ // session, no CSRF and no owner check ahead of it. Its whole security
+ // model lives inside handleSESEvents: a TopicArn allowlist, a
+ // label-aware SigningCertURL host check, and a verified signature,
+ // all run before any field of the message is trusted.
+ {Pattern: "POST /api/ses/events", Handler: (*Server).handleSESEvents},
+ {Pattern: "POST /api/fleet/enrol", Handler: (*Server).handleManagedEnrol},
+ // The box door of interactive sessions (apiinteractivebox.go, rootfs
+ // apps spec §5.10): no console principal either. The box that owns a
+ // session's instance proves itself with the session's own token from
+ // its grant and, on a fleet, its fleet identity; every refusal is the
+ // same 404. lifetimesExempt names its prefix (interactive.
+ // AttachPathPrefix, the path every grant's Attach URL carries): it
+ // touches no record.
+ {Pattern: "GET /api/box/interactive/{id}", Handler: (*Server).handleBoxInteractive},
+ // The run door (apirunsbox.go, rootfs apps Plan 6 Task 16): a fleet
+ // box carries one run over it, and the console makes the run's bucket
+ // writes. The box door's gate: the run's own token from its grant and
+ // the fleet identity; every refusal is the same 404. lifetimesExempt
+ // names its prefix (interactive.RunAttachPathPrefix): the connection
+ // holds no unit, and each record write is a step of its own.
+ {Pattern: "GET /api/box/runs/{id}", Handler: (*Server).handleBoxRun},
+ // Billing webhook (billingwebhook.go, plans 6a): UNAUTHENTICATED for
+ // the same reason; the provider's signature is checked before anything
+ // in the body is used, and the body only names what to re-read. Always
+ // registered: with billing off it answers 404.
+ {Pattern: "POST /billing/webhook", Handler: (*Server).handleBillingWebhook},
+}
+
+// registerDecls is THE loop: every declaration match accepts and whose gate
+// holds for s.cfg is passed to its kind's helper. NewServer calls it once
+// with a match-all; tests that re-register a group after flipping config
+// call it with a gate match.
+func (s *Server) registerDecls(match func(routeDecl) bool) {
+ for _, d := range routeDecls {
+ if d.Gate != nil && !d.Gate.holds(s.cfg) {
+ continue
+ }
+ if !match(d) {
+ continue
+ }
+ if (d.Handler == nil) == (d.Build == nil) {
+ panic("console: route " + d.Pattern + " must set exactly one of Handler and Build")
+ }
+ var h http.HandlerFunc
+ if d.Handler != nil {
+ handler := d.Handler
+ h = func(w http.ResponseWriter, r *http.Request) { handler(s, w, r) }
+ } else {
+ h = d.Build(s)
+ }
+ switch d.Kind {
+ case kindPlain:
+ s.registerRoute(d.Pattern, h)
+ case kindCLI:
+ s.cliRoute(d.Pattern, d.Allow, h)
+ case kindCLIJournaled:
+ refused := d.Refused
+ s.cliRouteJournaled(d.Pattern, d.Allow, h, func(r *http.Request, p Principal, status int) { refused(s, r, p, status) })
+ case kindCLIScoped:
+ s.cliScopedRoute(d.Pattern, d.Allow, d.Target, h)
+ default:
+ panic(fmt.Sprintf("console: route %s has unknown kind %d", d.Pattern, d.Kind))
+ }
+ }
+}
diff --git a/internal/console/server.go b/internal/console/server.go
index 797b15c9e..8911ace2b 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -70,7 +70,6 @@ import (
"github.com/carlosframework/platform/internal/svcrole"
"github.com/carlosframework/platform/internal/telemetry"
"github.com/carlosframework/platform/internal/usage"
- "github.com/carlosframework/platform/internal/version"
"github.com/carlosframework/platform/internal/zonehost"
)
@@ -1930,85 +1929,6 @@ func NewServer(cfg Config, st *Store) (*Server, error) {
}
// No goroutine is started here: StartAlertEngine is serve()'s job, so a
// test that constructs a Server gets a Server and nothing else.
- s.registerRoute("GET /{$}", s.handleHome)
- s.registerRoute("GET /static/{hash}/{file...}", s.handleStatic)
- s.registerRoute("POST /auth/continue", s.handleContinue)
- s.registerRoute("GET /auth/email/link", s.handleEmailLinkPage)
- s.registerRoute("POST /auth/email/link", s.handleEmailLink)
- s.registerRoute("POST /auth/email/code", s.handleEmailCode)
- s.registerRoute("POST /auth/email/stepup/code", s.handleStepUpEmailCode)
- s.registerRoute("GET /auth/signin", s.handleSignin)
- s.registerRoute("GET /auth/callback", s.handleCallback)
- // Passkey step-up (stepup.go): where a re-authentication lands, on its own
- // route so a step-up code and a sign-in code are never interchangeable.
- s.registerRoute("GET /auth/stepup/callback", s.handleStepUpCallback)
- s.registerRoute("GET /auth/confirm", s.handleConfirm)
- s.registerRoute("POST /auth/signout", s.handleSignout)
- s.registerRoute("GET /fleet", s.handleDashboard)
- s.registerRoute("GET /fleet/activity", s.handleActivity)
- s.registerRoute("GET /fleet/boxes", s.handleBoxes)
- s.registerRoute("GET /fleet/index", s.handleOpIndex)
- s.registerRoute("GET /fleet/people", s.handlePeople)
- s.registerRoute("GET /fleet/people/{address}", s.handlePerson)
- s.registerRoute("GET /fleet/store", s.handleStoreApprovalsPage)
- s.registerRoute("POST /fleet/store/{account}/{decision}", s.handleStoreDecisionPage)
- s.registerRoute("POST /a/{sqid}/store/apply", s.handleStoreApplyPage)
- s.registerRoute("GET /fleet/metrics", s.handleFleetMetrics)
- // Fleet alerts (alertpages.go): the operator pages, same gate. Their
- // writes are registered without a method, as the economics doors below
- // are and for the same reason: a wrong method answers the unknown
- // route's 404, never a 405 that says the door is there.
- s.registerRoute("GET /fleet/alerts", s.handleFleetAlerts)
- s.registerRoute("GET /fleet/alerts/history", s.handleFleetAlertHistory)
- s.registerRoute("/fleet/alerts/connectors", s.handleAlertConnectorAdd)
- s.registerRoute("/fleet/alerts/connectors/{id}/test", s.handleAlertConnectorTest)
- s.registerRoute("/fleet/alerts/connectors/{id}/confirm-link", s.handleAlertConnectorConfirmLink)
- s.registerRoute("/fleet/alerts/connectors/{id}/delete", s.handleAlertConnectorDelete)
- s.registerRoute("/fleet/alerts/rules/{rule}", s.handleAlertRuleSave)
- // The links alert messages carry, public: the token is the credential.
- // Each GET shows a page and acts on nothing; only the POST acts, so a
- // scanner that opens every link in a mail changes nothing.
- s.registerRoute("GET /alerts/confirm/{token}", s.handleAlertConfirmPage)
- s.registerRoute("POST /alerts/confirm/{token}", s.handleAlertConfirm)
- s.registerRoute("GET /alerts/unsubscribe/{token}", s.handleAlertUnsubscribePage)
- s.registerRoute("POST /alerts/unsubscribe/{token}", s.handleAlertUnsubscribe)
- s.registerRoute("GET /alerts/snooze/{token}", s.handleAlertSnoozePage)
- s.registerRoute("POST /alerts/snooze/{token}", s.handleAlertSnooze)
- s.registerRoute("GET /alerts/signing-key", s.handleAlertSigningKey)
- s.registerRoute("GET /fleet/economics", s.handleEconomics)
- // The operator's Protection page (protectionview.go) and its JSON door:
- // what the edge guard did across every app. Operators only, as Economics.
- s.registerRoute("GET /fleet/protection", s.handleFleetProtection)
- s.registerRoute("GET /fleet/protection/data", s.handleFleetProtectionData)
- // The deployment's map (archpage.go), same operatorOnly gate. BOTH are
- // registered WITHOUT a method prefix, for the reason spelled out below
- // the economics doors: a "GET /path" pattern answers a POST with 405 +
- // Allow, which distinguishes this route from an unrouted one to anyone
- // who merely guessed the URL — the exact probe the gate exists to
- // prevent. Each handler checks r.Method itself, first thing.
- s.registerRoute("/fleet/architecture", s.handleArchitecture)
- s.registerRoute("/fleet/architecture/refresh", s.handleArchitectureRefresh)
- // Per-account table (Task 14): same gate, its own search/filter/cursor
- // controls (econlistquery.go) over the same LoadEconomics rows.
- s.registerRoute("GET /fleet/economics/accounts", s.handleEconomicsAccounts)
- // Unit economics (Task 12): scenario/bill writes, operator-only, same
- // gate shape as handleDashboard above. GET /fleet/economics is handled
- // above by handleEconomics (Task 13). Registered WITHOUT a method
- // prefix, deliberately: a
- // "POST /path" pattern answers a GET with 405 + Allow, which leaks that
- // the route exists to someone who merely guessed the URL — the exact
- // probe operatorOnly's 404-to-everyone gate exists to prevent. Each
- // handler below checks r.Method itself, before anything else, so a
- // wrong-method request is byte-identical to an unknown route.
- s.registerRoute("/fleet/economics/scenarios", s.handleEconomicsScenarioSave)
- s.registerRoute("/fleet/economics/bill", s.handleEconomicsBillSave)
- s.registerRoute("/api/economics/bill", s.handleAPIEconomicsBill)
- s.registerRoute("/api/economics/backhaul", s.handleAPIEconomicsBackhaul)
- // Account tier (economics-v2, Task 4): same bare-registration/method-
- // first reasoning as the two doors above.
- s.registerRoute("/fleet/economics/tier", s.handleEconomicsTierSave)
- // CLI identity: the device-code login `carlos auth login` drives, the
- // approval page, and the tokens an owner can see and kill (authcli.go).
// The db door's production replica reader (apidb.go); tests repoint it.
if cfg.HostClaim {
s.dbHandleKey = dbHandleSecret(key)
@@ -2018,246 +1938,18 @@ func NewServer(cfg Config, st *Store) (*Server, error) {
s.dbStreamIdle = dbStreamIdleDefault
s.dbReads = newDBStreamLimits(dbreads.OpenPerConsole, dbreads.OpenPerPerson)
s.dbf = defaultDBForwardTimes()
+ // Every route the console serves, from routeDecls (routedecls.go):
+ // after every piece of state above, each declaration whose gate holds
+ // for this configuration.
+ s.registerDecls(func(routeDecl) bool { return true })
+ // CLI identity: the device-code login `carlos auth login` drives, the
+ // approval page, and the tokens an owner can see and kill (authcli.go).
s.registerCLIRoutes()
// The email API's ten doors (apimail.go, tenant-email task 17) —
// registered separately from registerCLIRoutes because this task's file
// scope is server.go and apimail.go only.
s.registerEmailRoutes()
- // Account-scoped and explicit: /a/<sqid>/apps/<app> rather than
- // account-by-session, so a link a teammate opens lands where you meant.
- s.registerRoute("GET /a/{sqid}/{$}", s.handleAccountHome)
- s.registerRoute("GET /a/{sqid}/index", s.handleAccountIndex)
- s.registerRoute("GET /a/{sqid}/fleet", s.handleAccountFleetTab)
- s.registerRoute("GET /a/{sqid}/fleet/byo", s.handleFleetBYO)
- s.registerRoute("GET /a/{sqid}/team", s.handleTeam)
- s.registerRoute("GET /a/{sqid}/settings", s.handleAccountSettings)
- s.registerRoute("POST /a/{sqid}/errors/level", s.handleAccountErrorLevel)
- s.registerRoute("POST /a/{sqid}/analytics/setting", s.handleAccountAnalyticsSetting)
- // Plans 4d: owners choose what stays after a lapse (planlapse_keep.go).
- s.registerRoute("GET /a/{sqid}/plan/keep", s.handlePlanKeep)
- s.registerRoute("POST /a/{sqid}/plan/keep", s.handlePlanKeepSave)
- // Plans 6b: an owner's Confirm now finishes a billing operation left
- // without a definite outcome (billingops.go). 404 with billing off.
- s.registerRoute("POST /a/{sqid}/billing/confirm", s.handleBillingConfirm)
- // Plans 6b: Checkout (billingcheckout.go). The owner's buy and Start over
- // POST, Continue back to an open payment page, and the return from it.
- // 404 with billing off.
- s.registerRoute("POST /a/{sqid}/billing/checkout", s.handleBillingCheckout)
- s.registerRoute("GET /a/{sqid}/billing/continue", s.handleBillingContinue)
- s.registerRoute("GET /a/{sqid}/billing/done", s.handleBillingDone)
- // Plans 6b: an owner's pack change or plan upgrade, and stopping or
- // resuming renewal (billingchange.go). 404 with billing off.
- s.registerRoute("POST /a/{sqid}/billing/change", s.handleBillingChange)
- s.registerRoute("POST /a/{sqid}/billing/renewal", s.handleBillingRenewal)
- // Plans 6b: an owner's Match seats to members (billingseats.go). 404
- // with billing off.
- s.registerRoute("POST /a/{sqid}/billing/seats", s.handleBillingSeats)
- // Plans 6b: an owner's way to the provider's locked portal for cards
- // and invoices (billingportal.go). 404 with billing off.
- s.registerRoute("POST /a/{sqid}/billing/portal", s.handleBillingPortal)
- s.registerRoute("POST /a/{sqid}/billing/card", s.handleBillingCard)
- // The billing page (billingpage.go): member-readable, its forms the
- // owner's. 404 with billing off.
- s.registerRoute("GET /a/{sqid}/billing", s.handleBilling)
- // Go 1.22's mux prefers this literal over apps/{app} below — exactly why
- // "new" must be a reserved app name (claimApp): an app so named could
- // never be viewed.
- s.registerRoute("GET /a/{sqid}/apps/new", s.handleNewAppForm)
- s.registerRoute("POST /a/{sqid}/apps/new", s.handleNewApp)
- s.registerRoute("POST /a/{sqid}/apps/new/region", s.handleNewAppRegion)
- s.registerRoute("GET /a/{sqid}/apps/{app}/source", s.handleBrowserAppSource)
- s.registerRoute("GET /a/{sqid}/apps/{app}", s.handleApp)
- s.registerRoute("GET /a/{sqid}/apps/{app}/index", s.handleAppIndex)
- s.registerRoute("GET /a/{sqid}/apps/{app}/releases", s.handleAppReleases)
- // The retired Deployments tab: Live now on the Releases page took its
- // table. accountApp's gates run before the 303.
- s.registerRoute("GET /a/{sqid}/apps/{app}/deployments", s.handleAppDeploymentsRedirect)
- s.registerRoute("GET /a/{sqid}/apps/{app}/account-review", s.handleAppAccountReview)
- s.registerRoute("GET /a/{sqid}/apps/{app}/instances", s.handleAppInstances)
- s.registerRoute("GET /a/{sqid}/apps/{app}/instances/{host}", s.handleAppInstance)
- s.registerRoute("POST /a/{sqid}/apps/{app}/restart", s.handleAppRestart)
- s.registerRoute("POST /a/{sqid}/apps/{app}/instances/{host}/restart", s.handleInstanceRestart)
- s.registerRoute("POST /a/{sqid}/apps/{app}/instances/{host}/retry", s.handleInstanceRetry)
- s.registerRoute("POST /a/{sqid}/apps/{app}/instances/{host}/updates", s.handleBrowserUpdates)
- s.registerRoute("POST /a/{sqid}/apps/{app}/instances/{host}/updates/install", s.handleBrowserUpdateNow)
- s.registerRoute("GET /a/{sqid}/apps/{app}/logs", s.handleAppLogs)
- s.registerRoute("GET /a/{sqid}/apps/{app}/logs/data", s.handleAppLogsData)
- // The Errors tab and its two setting doors (errorsview.go): the tab is
- // member-readable like every other app tab; the level is the owner's,
- // at app and account level, and both POSTs go through the console gate
- // (CSRF, then owner, then the byte-identical 404).
- s.registerRoute("GET /a/{sqid}/apps/{app}/errors", s.handleAppErrors)
- s.registerRoute("POST /a/{sqid}/apps/{app}/errors/level", s.handleAppErrorLevel)
- // Availability (errorsview.go): the Errors tab's sibling for the
- // failures that are the instance's, not the request's — edge 502/503/504
- // by cause and the platform's lifecycle events. Member-readable, no
- // setting of its own.
- s.registerRoute("GET /a/{sqid}/apps/{app}/availability", s.handleAppAvailability)
- // The Analytics tab (analyticsview.go) and the switch beside it. The tab
- // is member-readable like every other app tab; the switch rides the same
- // gate the errors level does at both levels, and bumps the serial where
- // the errors level does not: a box acts on whether the edge counts.
- s.registerRoute("GET /a/{sqid}/apps/{app}/analytics", s.handleAppAnalytics)
- s.registerRoute("GET /a/{sqid}/apps/{app}/analytics/live", s.handleAnalyticsLive)
- s.registerRoute("POST /a/{sqid}/apps/{app}/analytics/setting", s.handleAppAnalyticsSetting)
- // The Protection tab (protectionview.go) and its JSON door: what the
- // edge guard checked, recorded and blocked for the app. Member-readable
- // like the Analytics tab, through the same gate.
- s.registerRoute("GET /a/{sqid}/apps/{app}/protection", s.handleAppProtection)
- s.registerRoute("GET /a/{sqid}/apps/{app}/protection/data", s.handleAppProtectionData)
- s.registerRoute("POST /a/{sqid}/apps/{app}/protection/setting", s.handleAppProtectionSetting)
- s.registerRoute("GET /a/{sqid}/apps/{app}/activity", s.handleAppActivity)
- s.registerRoute("GET /a/{sqid}/apps/{app}/settings", s.handleAppSettings)
- s.registerRoute("GET /a/{sqid}/apps/{app}/settings/{section}", s.handleAppSettings)
- s.registerRoute("GET /a/{sqid}/apps/{app}/settings/index", s.handleAppSettingsIndex)
- // The Environments section's one form (envform.go): any member, CSRF;
- // staging re-renders, Save writes one bundle.
- s.registerRoute("POST /a/{sqid}/apps/{app}/settings/environments", s.handleEnvForm)
- // The pipeline settings page (pipelinepage.go, release pipelines v2 §5)
- // is the Settings tab's Release pipeline section; the old GET answers
- // with a 303 to it, after accountApp's gates. POST goes through the same
- // guarded path the API PUT does, and keeps this path.
- s.registerRoute("GET /a/{sqid}/apps/{app}/pipeline", s.handleAppPipelineRedirect)
- s.registerRoute("POST /a/{sqid}/apps/{app}/pipeline", s.handlePipelineSettingsSave)
- s.registerRoute("POST /a/{sqid}/apps/{app}/promote", s.handlePromote)
- s.registerRoute("POST /a/{sqid}/apps/{app}/rollback", s.handleRollback)
- s.registerRoute("POST /a/{sqid}/apps/{app}/production", s.handleProduction)
- s.registerRoute("POST /a/{sqid}/apps/{app}/fasttrack", s.handleFastTrack)
- // The pending-change doors (pendinghandlers.go, release pipelines v2 §4):
- // confirm is member-gated with the passkey step-up LAST, reject is the
- // proposer's or an owner's and deliberately carries no step-up — refusing
- // authority is not exercising it.
- s.registerRoute("POST /a/{sqid}/apps/{app}/pending/{id}/confirm", s.handlePendingConfirm)
- s.registerRoute("POST /a/{sqid}/apps/{app}/pending/{id}/reject", s.handlePendingReject)
- s.registerRoute("POST /a/{sqid}/apps/{app}/canary", s.handleNewCanary)
- s.registerRoute("POST /a/{sqid}/apps/{app}/canary/retire", s.handleRetireCanary)
- // The app Settings writes (appsettings.go): owner-only, and delete/move
- // behind passkey step-up besides.
- s.registerRoute("POST /a/{sqid}/apps/{app}/place", s.handleAppPlace)
- // The password-gate form (appsettings.go's handleAppGate): member-gated,
- // unlike the owner-only writes above it.
- s.registerRoute("POST /a/{sqid}/apps/{app}/gate", s.handleAppGate)
- // The rate-limit form beside it (handleAppRateLimit): member-gated too.
- s.registerRoute("POST /a/{sqid}/apps/{app}/ratelimit", s.handleAppRateLimit)
- // The Deploys card's form (appswap.go): member-gated, like the gate.
- s.registerRoute("POST /a/{sqid}/apps/{app}/swap", s.handleAppSwap)
- s.registerRoute("POST /a/{sqid}/apps/{app}/rename", s.handleAppRename)
- s.registerRoute("POST /a/{sqid}/apps/{app}/region", s.handleAppRegionSet)
- s.registerRoute("POST /a/{sqid}/apps/{app}/keep", s.handleAppKeep)
- // The app list's star (any member, the viewer's own) and Extend form
- // (owners) (applist.go).
- s.registerRoute("POST /a/{sqid}/apps/{app}/star", s.handleAppStar)
- s.registerRoute("POST /a/{sqid}/apps/{app}/extend", s.handleAppExtend)
- // The Getting started card's preferences (any member, the viewer's own)
- // (gettingstarted_handlers.go).
- s.registerRoute("POST /a/{sqid}/getting-started/hide", s.handleGettingStartedHide)
- s.registerRoute("POST /a/{sqid}/getting-started/show", s.handleGettingStartedShow)
- s.registerRoute("POST /a/{sqid}/getting-started/skip", s.handleGettingStartedSkip)
- s.registerRoute("POST /a/{sqid}/getting-started/done", s.handleGettingStartedDone)
- s.registerRoute("POST /a/{sqid}/apps/{app}/delete", s.handleAppDelete)
- s.registerRoute("POST /a/{sqid}/apps/{app}/move", s.handleAppMoveAccount)
- // The control-plane flag's two directions, both browser-only and both
- // owner-only. Clearing is passkey-gated, setting is not — the asymmetry
- // is spec §6's, and there is deliberately no API sibling for either
- // (controlplane.go).
- s.registerRoute("POST /a/{sqid}/apps/{app}/control-plane/clear", s.handleAppControlPlaneClear)
- s.registerRoute("POST /a/{sqid}/apps/{app}/control-plane/set", s.handleAppControlPlaneSet)
- // Domain purchases: owner sessions, with CSRF on both form posts.
- s.registerRoute("GET /a/{sqid}/apps/{app}/domains/buy", s.handleAppDomainBuyForm)
- s.registerRoute("POST /a/{sqid}/apps/{app}/domains/check", s.handleAppDomainBuyCheck)
- s.registerRoute("POST /a/{sqid}/apps/{app}/domains/buy", s.handleAppDomainBuy)
- s.registerRoute("GET /a/{sqid}/apps/{app}/domains/purchases/{id}", s.handleAppDomainPurchase)
- s.registerRoute("GET /a/{sqid}/apps/{app}/domains/purchases/{id}/status", s.handleAppDomainPurchaseStatus)
- // Custom domain attach/detach (appdomains.go, #82): owner-only, no
- // passkey step-up (spec §6) — detach's guard is the typed-host confirm.
- s.registerRoute("POST /a/{sqid}/apps/{app}/domains/attach", s.handleAppDomainAttach)
- s.registerRoute("POST /a/{sqid}/apps/{app}/domains/detach", s.handleAppDomainDetach)
-
- // Customer fleets (Task 9): the owner's own remote boxes and what's
- // placed on them — member-readable, owner-gated for rotate/detach
- // (fleets.go).
- s.registerRoute("GET /a/{sqid}/fleets/{fleet}", s.handleFleetPage)
- s.registerRoute("POST /a/{sqid}/fleets/{fleet}/rotate", s.handleFleetRotateBoxPage)
- s.registerRoute("POST /a/{sqid}/fleets/{fleet}/detach", s.handleFleetDetachBoxPage)
- s.registerRoute("POST /a/{sqid}/fleets/{fleet}/tags", s.handleFleetTagBoxPage)
- s.registerRoute("POST /a/{sqid}/fleets/{fleet}/place", s.handleFleetPlacePage)
- // The object store's destroy door (appsettings.go, issue #55): the account
- // owner, the bucket name typed out, and a passkey. It is the only console
- // route that destroys a customer's objects outside the app trash, and
- // unlike the trash there is no cooloff behind it.
- s.registerRoute("POST /a/{sqid}/apps/{app}/store/destroy", s.handleStoreDestroy)
- s.registerRoute("POST /a/{sqid}/invite", s.handleInvite)
- s.registerRoute("POST /a/{sqid}/invite/revoke", s.handleRevokeInvite)
- // Owner-only account administration, every one of them behind passkey
- // step-up as well as ownership and CSRF (ownership.go, spec §7a).
- s.registerRoute("POST /a/{sqid}/members/remove", s.handleRemoveMember)
- s.registerRoute("POST /a/{sqid}/members/transfer", s.handleTransferOwnership)
- s.registerRoute("POST /a/{sqid}/delete", s.handleDeleteAccount)
- // The service-credential pane's writes (svcpage.go, issue #220):
- // owner-only, and create/rotate behind passkey step-up besides. Revoke
- // deliberately is NOT — it is the emergency control, and it must not sit
- // behind a round trip that fails closed. See svcpage.go's doc comment.
- s.registerRoute("POST /a/{sqid}/services/new", s.handleServiceCreatePage)
- s.registerRoute("POST /a/{sqid}/services/rotate", s.handleServiceRotatePage)
- s.registerRoute("POST /a/{sqid}/services/revoke", s.handleServiceRevokePage)
- s.registerRoute("GET /a/{sqid}/trash", s.handleTrash)
- s.registerRoute("POST /a/{sqid}/trash/restore", s.handleRestoreApp)
- s.registerRoute("POST /a/{sqid}/trash/delete", s.handlePurgeApp)
- // GET only shows the invitation; joining is the POST its button sends
- // (discussion #219, item 4).
- s.registerRoute("GET /invite/{token}", s.handleInvitePage)
- s.registerRoute("POST /invite/{token}", s.handleAcceptInvite)
- s.registerRoute("GET /accounts", s.handleAccountsIndex)
- s.registerRoute("GET /accounts/new", s.handleNewAccountForm)
- // The upgrade entry the public pricing page links to (billingpage.go,
- // plans 6b Call 1): signed out, the front door with next; signed in,
- // the billing page of the account the viewer owns. 404 with billing off.
- s.registerRoute("GET /upgrade", s.handleUpgrade)
- s.registerRoute("POST /accounts/new", s.handleNewAccount)
- // The pre-accounts URLs, kept as redirects so old links and bookmarks
- // still land somewhere sensible rather than 404ing.
- s.registerRoute("GET /apps", s.handleLegacyApps)
- s.registerRoute("GET /apps/{app}", s.handleLegacyApp)
- // "ok <build>" — the build comes from THIS PROCESS (ldflags, at link
- // time), which is the whole point: X-Carlos-Version is stamped by the
- // edge from the route row, so it reports the version adoption INTENDED
- // from the moment the symlink moves, whether or not anything restarted.
- // `carlos deploy` polls this instead for any app declaring a build probe.
- //
- // "ok" stays the first token: internal/vet and the edge health probe read
- // this endpoint and check status, not body, but keeping the prefix means
- // a human or a script eyeballing it sees what it always saw.
- s.registerRoute("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintln(w, "ok", version.Build)
- })
- // SES event ingest (sesevents.go, tenant-email spec §9): UNAUTHENTICATED,
- // like healthz above — SNS is not a signed-in member, so there is no
- // session, no CSRF and no owner check ahead of it. Its whole security
- // model lives inside handleSESEvents: a TopicArn allowlist, a
- // label-aware SigningCertURL host check, and a verified signature,
- // all run before any field of the message is trusted.
- s.registerRoute("POST /api/ses/events", s.handleSESEvents)
- s.registerRoute("POST /api/fleet/enrol", s.handleManagedEnrol)
- // The box door of interactive sessions (apiinteractivebox.go, rootfs
- // apps spec §5.10): no console principal either. The box that owns a
- // session's instance proves itself with the session's own token from
- // its grant and, on a fleet, its fleet identity; every refusal is the
- // same 404. lifetimesExempt names its prefix (interactive.
- // AttachPathPrefix, the path every grant's Attach URL carries): it
- // touches no record.
- s.registerRoute("GET /api/box/interactive/{id}", s.handleBoxInteractive)
- // The run door (apirunsbox.go, rootfs apps Plan 6 Task 16): a fleet
- // box carries one run over it, and the console makes the run's bucket
- // writes. The box door's gate: the run's own token from its grant and
- // the fleet identity; every refusal is the same 404. lifetimesExempt
- // names its prefix (interactive.RunAttachPathPrefix): the connection
- // holds no unit, and each record write is a step of its own.
- s.registerRoute("GET /api/box/runs/{id}", s.handleBoxRun)
- // Billing webhook (billingwebhook.go, plans 6a): UNAUTHENTICATED for
- // the same reason; the provider's signature is checked before anything
- // in the body is used, and the body only names what to re-read. Always
- // registered: with billing off it answers 404.
- s.registerRoute("POST /billing/webhook", s.handleBillingWebhook)
+
// Catch up on accounts minted outside this database — `carlos accounts
// create` writes the bucket manifest and the registry row and never opens
// console state. Startup is the natural place: the account switcher, the