Skip to content

feat(settings): cell URL + generated cellToken for server investigations - #136

Merged
coccyx merged 2 commits into
masterfrom
settings-cell-token
Aug 13, 2026
Merged

feat(settings): cell URL + generated cellToken for server investigations#136
coccyx merged 2 commits into
masterfrom
settings-cell-token

Conversation

@coccyx

@coccyx coccyx commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Cell URL field and a generated cell token to the Settings "Server-side investigations" card, so an operator can wire the app to the server-side investigator cell without hand-editing KV or pasting secrets on both sides by memory.

The cell authenticates every request against a shared bearer: the app-scoped KV key cellToken (injected by proxies.yml as kv.cellToken) must equal the cell's UI_BEARER secret. This PR generates that token in the browser and shows it for copy into the cell.

What changed

  • Generate cell token — creates a 32-byte random hex token (openssl rand -hex 32 shape) via crypto.getRandomValues, stores it raw in the app KV store under cellToken (so the proxy injects it verbatim), and displays it read-only for copy into the cell's UI_BEARER.
  • Cell URL — persists to AppSettings.cellUrl and pushes into the transport via setCellBaseUrl. Must match the domain declared in config/proxies.yml, or the platform proxy blocks the fetch.
  • Corrected stale toggle text — the cell no longer self-gates on the flag (removed in cell fix(cell): don't self-gate on the serverInvestigations flag #133), so "the cell re-checks this flag on every trigger" was false; reworded to describe the re-provision behavior.
  • Version bump 0.13.28 → 0.13.29 so the pack actually installs on staging.

Validate on staging

Deployed as apm-0.13.29.tgz.

  1. Open the APM app → SettingsServer-side investigations card.
  2. Click Generate cell token → a hex token appears in the read-only field; tap to select-all and copy.
  3. (Optional) set Cell URL and Save cell URL.
  4. Confirm the token persists across a reload (read back from KV cellToken on mount).

Cell side (separate infra VM)

Set the same value as the cell's UI_BEARER secret and restart the cell:

aws ssm put-parameter --profile test --region us-west-2 \
  --name /apm-cell/UI_BEARER --type SecureString \
  --value '<TOKEN_FROM_SETTINGS>' --overwrite

App KV cellToken must match cell SSM /apm-cell/UI_BEARER exactly, or the cell rejects every proxied request as unauthorized.

Known limitations

  • No copy-to-clipboard button yet (sandboxed-iframe clipboard is finicky); the field is select-on-focus so long-press / Ctrl-A + copy works.
  • Kept up to date as follow-on server-investigations changes land.

🤖 Generated with Claude Code

coccyx and others added 2 commits August 13, 2026 14:43
The UI transport had nowhere to reach: config/proxies.yml was empty
and getCellBaseUrl() returned ''. Declare the cell domain and point
the transport at it.

- config/proxies.yml: the cell host (EIP-derived sslip.io behind
  Caddy TLS), path allowlist /investigations, and header inject
  Authorization: 'Bearer ' + kv.cellToken — the iframe can't set the
  header itself, so the platform proxy injects it from encrypted KV.
- config/proxies.expected.yml + swap --require-empty-proxies →
  --proxies-manifest (framework #22 tooling): the release now pins
  the exact reviewed manifest instead of requiring it empty. Verified:
  npm run package && inspect:pack passes against the pinned manifest.
- getCellBaseUrl() defaults to the proxies.yml domain, overridable by
  a cellUrl app setting (hydrated in DatasetProvider) so a cell
  redeploy under a new host needs a settings change, not a rebuild —
  but it must match proxies.yml or the proxy blocks it.

Requires the cellToken encrypted-KV secret (= the cell's UI_BEARER)
to be created by an admin — a one-time deploy step.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The server-investigator cell authenticates every request against a
shared bearer: the app-scoped KV key `cellToken` (injected by
proxies.yml as `kv.cellToken`) must equal the cell's `UI_BEARER`
secret. Rather than ask the operator to hand-generate and paste a
token on both sides, the Settings "Server-side investigations" card
now:

- Generates a 32-byte random hex token in the browser
  (openssl-rand-hex-32 shape), stores it raw in KV under `cellToken`,
  and displays it read-only for copy into the cell's UI_BEARER.
- Lets the operator set the cell base URL (persisted to AppSettings
  `cellUrl`, pushed into the transport via setCellBaseUrl). Must match
  the domain in config/proxies.yml.

Also corrects the toggle sub-text: the cell no longer self-gates on
the flag (removed in the cell #133 change), so "the cell re-checks
this flag on every trigger" was stale.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158jez4WfWj6ttmaxh3HEbT
@coccyx
coccyx merged commit 13ac35b into master Aug 13, 2026
4 checks passed
@coccyx
coccyx deleted the settings-cell-token branch August 13, 2026 23:04
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