Skip to content

chore: spec — CORS wildcard+credentials blocks first-party /ingest - #289

Closed
fclairamb wants to merge 1 commit into
mainfrom
chore/spec-cors-first-party-ingest
Closed

fclairamb wants to merge 1 commit into
mainfrom
chore/spec-cors-first-party-ingest

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Spec only — no code change.

Found while checking whether www.solidping.io could route PostHog through the app's first-party /ingest proxy instead of the verbatim eu.i.posthog.com that ad blockers drop. It cannot, for three separate reasons, all in server/internal/app/server.go and all verified against production today:

  1. Access-Control-Allow-Origin: * is sent together with Access-Control-Allow-Credentials: true (lines 2193/2197). The Fetch standard forbids the pair, so the credentials header never takes effect and any credentialed cross-origin call is refused. Whole API, no allowlist, no config knob. Nothing is broken today because the dashboard is same-origin.
  2. proxyPostHog forwards PostHog's own CORS headers on top of ours, so Access-Control-Allow-Origin arrives twice (* and the echoed origin). Browsers reject a repeated ACAO outright; curl does not, which is why non-browser probes pass.
  3. The proxy registers only GET and POST (lines 2146-2147), so a preflight OPTIONS gets 405 with no CORS headers at all.

Business consequence: the proxy exists so ad blockers stop dropping analytics, but it only works same-origin. www — whose audience blocks trackers at the highest rate of any population we have — is stuck on the verbatim host, so launch-day numbers there will be undercounted.

Proposal in the spec: origin allowlist + Vary: Origin, strip upstream CORS in ModifyResponse, register OPTIONS, and assert header counts in the tests (an assertion that reads one value passes while the response is broken).

🤖 Generated with Claude Code

@fclairamb

Copy link
Copy Markdown
Owner Author

Superseded by #288 — merged into batch/2026-08-29, and the spec is now implemented there: CORS wildcard+credentials replaced with a config-driven allowlist, upstream Access-Control-* headers stripped in the ingest proxy, and OPTIONS registered on the proxy path. Archived at specs/done/2026/08/2026-08-30-09-cors-blocks-first-party-ingest.md. Closing in favour of #288.

@fclairamb fclairamb closed this Aug 31, 2026
fclairamb added a commit that referenced this pull request Aug 31, 2026
…ng commands, CORS allowlist (#288)

Batch branch off `v0.20.0`, covering **24 specs**, and absorbing PRs
#285 and #289. Every spec was implemented, gated on its own scoped
build/lint/test run, and then cleared by an **independent completeness
audit** before being archived to `specs/done/2026/08/`. `specs/todos/`
is now empty.

#285 (Slack Marketplace readiness) was already an ancestor of this
branch — its content landed here earlier, so merging it was a no-op.
#289 contributed the CORS spec, which is implemented below. Both can be
closed in favour of this PR.

> **Note on the changelog:** the repo squash-merges with the PR title as
the commit subject, so this whole branch lands as the *single* changelog
line above. Per-spec detail lives here and in `specs/done/2026/08/`.

## ⚠️ Needs action outside this repo

- **The `/saas/slack` command table on `www.solidping.io` is now
wrong.** It still advertises the standalone `/check` and `/comment`
commands and the `setup`/`ack` subcommands, none of which exist any
more. That page lives in the separate `solidping-website` repo, so this
PR cannot touch it. It needs a single `/solidping` entry documenting:
`check <url>`, `comment [#N] <text>`, `list`, `create <url>`, `config`,
`incidents`, `help`.

## ⚠️ Pulling this branch? Your dev database may silently miss columns

`017_v0_21_0` is the single consolidated migration for the unreleased
v0.21.0, and it was **appended to twice** during this batch — first the
kiosk-token section, later the section-selector section. bun keys
applied migrations on the numeric prefix alone, so any dev database that
ran `017` between those two commits has it recorded as done and will
**never** pick up the appended statements. The symptom is a 500 on
status-page create: `table status_page_sections has no column named
selector`.

`migrationguard` catches this and logs it on every boot (WARN in dev,
fail in strict). To fix a database that is already in that state, either
reset it, or apply the missing statements by hand and run `solidping
migrate repair`. SQLite form:

```sql
alter table status_page_sections add column selector text;
alter table status_page_resources add column managed_by_selector boolean not null default false;
create index if not exists status_page_sections_selector_idx
  on status_page_sections (status_page_uid)
  where selector is not null and deleted_at is null;
```

The Postgres half is the same three statements with `selector` as
`jsonb` and `if not exists` guards — take them from
`postgres/migrations/017_v0_21_0.up.sql`.

Nothing deployed is affected — `016` is the last released migration.

## ⚠️ Behaviour changes worth a reviewer's attention

- **`/check` and `/comment` are retired as standalone Slack commands.**
Both are removed from the dev and prod manifests. Their dispatch arms
are deliberately **kept** for one release, answering ephemerally with
"this moved to `/solidping check`" — a workspace that installed the old
manifest keeps its commands registered with Slack until it
re-authorizes, so deleting the arms would strand those installs on
`Unknown command`.
- **`setup` and `ack` were dropped** from the manifest usage hint rather
than implemented. The hint now names only subcommands that have
handlers, and a test reads the real manifest files and asserts exactly
that, so the two cannot drift apart again.
- **The organization section now defaults to Members**, not Invitations,
matching its own tab order.
- **`bun`'s `default:` tag was dropped from every non-timestamp
column.** The tag made bun omit zero values from INSERTs, so an explicit
`0`/`false`/`""` on create silently became the schema default. This is a
repo-wide data-correctness change and the widest-blast-radius commit on
the branch.
- **CI now starts the E2E server with self-registration enabled**
(`SP_AUTH_REGISTRATION_EMAIL_PATTERN`), required for the
confirm-registration spec to run at all. Side effect:
`membership-requests.spec.ts` no longer skips itself, so it executes in
CI for the first time.

## Features

### Status pages
- **TV / wallboard mode** (`/{org}/{slug}/tv`, `/{org}/tv`, `/tv` on a
custom domain) — one non-scrolling viewport for a room at 4 m: ambient
state carried by icon *and* word *and* colour, active incidents cycled
rather than shrunk, "days since last incident", and a stale treatment
that drops the board to grey rather than leaving a frozen green screen
during an outage. Includes a page-level uptime aggregate and **revocable
kiosk tokens** so a wallboard can render a non-public page unattended.
- **Dynamic section selectors** — a section can carry a membership rule
(`{"all":true}` or `{"labels":{…}}`) and an idempotent reconciler
*materializes* real resource rows for it, flagged `managed_by_selector`,
so every downstream reader keeps working unchanged. Selector ownership
is enforced at the API boundary, provenance is hidden from the public
payload, and the reconciler re-runs after check writes.
- **Badge and widget previews link to the status page**, and —
separately — the **copyable
badge snippets are now links too**: `[![...](badge)](page)` and an
`<img>` wrapped in an
`<a rel="noopener noreferrer">`. A badge embedded on someone's README or
footer was an inert
image, which is the one thing a status badge must never be.
Operator-controlled page names
are now escaped for both the HTML `alt` attribute and the Markdown alt
brackets.
- **A selector section whose matches are claimed elsewhere now says
so.** Selector sections
dedupe page-wide — a check is claimed by the first section that matches
it — so a later
section could render completely empty and look exactly like a
label-matching bug. A real user
reported it as one. The editor now explains it ("All 2 matching checks
are already shown in
'All services'") with the remedy, via new admin-only payload fields that
never reach the
  public payload.

### Security and correctness
- **CORS `*` + credentials is spec-invalid, and it made `/ingest`
unusable from any other
origin.** `corsMiddleware` hardcoded `Access-Control-Allow-Origin: *`
together with
`Access-Control-Allow-Credentials: true` — a pairing the Fetch standard
forbids, so the
credentials flag never took effect for anyone and every credentialed
cross-origin caller was
  refused by the browser. Replaced with a **config-driven allowlist**
(`SP_CORS_ALLOWED_ORIGINS`, defaulting to the app's own public origin)
that echoes a matching
`Origin` with `Vary: Origin`. Genuinely public, credential-free surfaces
— status pages, the
embed widget, the ingest proxy — keep `*` **without** credentials, since
the domains that
embed them can never be enumerated. Separately, the PostHog proxy
forwarded upstream
`Access-Control-*` headers on top of our own, so clients saw each header
**twice** (which a
browser rejects outright and curl cannot detect), and the proxy had no
`OPTIONS` route, so
preflight got a bare `405` with no CORS headers at all. Both fixed.
Nothing was broken by this
in production today — the dashboard is same-origin — but it blocked
`www` from proxying its
  own analytics.

### Onboarding and navigation
- **One-click onboarding defaults** — a magic-wand action on the
integrations, report-schedules and status-page-create pages creates the
sensible default in one click, visible only while the corresponding
Getting Started step is outstanding.
- **The onboarding checklist card is tinted and its step rows are
clickable.**
- **Organization switching from the command palette**, plus the
ambiguous "Settings" entry renamed to "Organization Settings" without
touching the shared `nav:settings` key.
- **Quick-start check creation lands on the new check's page** instead
of a generic dashboard.
- **A magic-wand auto-create on the status pages list**, matching the
integrations wand: one
click builds a page named after the org with every check attached
(paging through the whole
list, so an org with >100 checks is not silently under-attached) at the
create form's own
defaults, then lands on the new page. The Getting Started checklist CTA
now targets the list
  rather than the blank form, so the wand is the first thing offered.

### Slack, WhatsApp and email
- **Slack slash commands actually work.** `/solidping` was registered in
both manifests and documented publicly, but had **no handler** — every
documented subcommand, `/solidping help` included, answered `Unknown
command`. It is now routed through the existing mention parser and
subcommand router, answering ephemerally, with `list`/`create` aliases.
`/solidping check` ACKs immediately and completes via `response_url`
instead of doing a DB write plus an outbound Slack call inside the
3-second budget.
- **Dark-mode email variants** — a designed dark palette in the shared
email stylesheet, with the preview served behind `?colorScheme=dark` and
a Light/Dark toggle in dash0.
- **WhatsApp read receipts** are sent when an operator reads or replies
to a support message.

### Docs
- **The changelog is published at `/docs/changelog`**, generated at
build time from the root `CHANGELOG.md` — reference clutter stripped,
dependency bumps filtered, scopes mapped to product-facing names. The
transform is deliberately tolerant: anything it doesn't recognise passes
through verbatim, so a malformed entry can never fail the docs build.

## Fixes

### Correctness (backend)
- **`configEqual` was type-blind**, so a type-only config edit never
reached `check_jobs` — the worker kept running the old config.
- **`PATCH /checks` skipped `checker.Validate`** on the merged config,
so an invalid partial update was accepted.
- **A cached rate-limit bucket kept stale capacity** after an
entitlements change, so a plan upgrade did not take effect until the
bucket expired.
- **`bun`'s `default:` tag swallowed zero values on create** (see
behaviour changes above).

### Auth and registration
- **Confirming a registration instantly logged the user out.** For a
brand-new email matching no org, the confirmation response carried no
session, so the frontend persisted the literal string `"undefined"` as a
token, 401'd on the next call, and bounced to login with "session
expired" — while the account *had* been created, so re-registering then
failed with email-taken. The zero-org branch now mints a real session,
and `setSession` refuses a falsy token.
- **`/register` 401-bounced** because `useFeatures` ran on a public
route.
- **`OrgLayout`'s auto-switch-org guard raced an explicit `switchOrg`.**

### TV wallboard
- **A red board named no failing check.** `overallStatus` is recomputed
from live check data on every poll, so the board turns red the instant a
probe fails, while `activeIncidents` are publications gated by
`autoPublishDelaySeconds` (60 s) — and absent entirely when auto-publish
is off. In that gap the board rendered a full-screen red *System Outage*
whose only text was "N days since the last incident". It now names the
failing checks, worst first, excluding those in a maintenance window; an
active publication still wins the panel.
- **Affected services now show how long they have been failing** — the
public resource payload gained `statusChangedAt` from the check's
existing `status_changed_at`. Check resources only: a group's status
rolls up from a count map with no timestamps, so the field is omitted
rather than guessed and the row renders without a duration.
- **The resolved strip says *when*, not just how long** — "3h 0m ago ·
lasted 8m" instead of "resolved in 8m".

### Notifications and UI
- **Slack ack/unack/comment/resolved/reopened thread replies now link
the incident first**, not the check.
- **Incident page comments rendered as plain text** and blended into the
Comments card.
- **The check detail page's docs icon** sat mid-toolbar instead of top
right; a second page had the same misplacement.

## Verification

Backend build/lint/test, dash0 and status0 build/lint, unit suites, and
— for every spec touching shared code — the **full** Playwright suite
rather than just the spec's own file. That policy earned its keep: it
caught a stale assertion left by the organization-tab change, a shared
React Query cache key making freshly created entities invisible to the
command palette, and three real API-shape bugs in new E2E tests. New
user-facing strings are in all four locales with real translations, and
a `tv-locales` guard test pins the TV keys so a new string cannot ship
in English only.

The TV fixes were additionally checked with a **positive control** —
reverting just the component and confirming the new assertions fail
against the old code — so the added tests are known to test something.

## Not included

`specs/todos/` is empty as of this branch. Two untracked drafts sit in
the working tree — `specs/backlog/2026-08-30-08-magic-link-login.md` and
`specs/todos/2026-08-30-09-status-pages-magic-wand-and-checklist-link.md`
— neither of which is committed here; they are follow-up material for
the next batch.

---------

Co-authored-by: Claude Opus 5 <[email protected]>
@fclairamb
fclairamb deleted the chore/spec-cors-first-party-ingest branch October 26, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant