Skip to content

[P1] F-9: apiCredentialsSet swaps credentials silently, no audit event#387

Open
divybot wants to merge 1 commit into
mainfrom
orch/issue-85
Open

[P1] F-9: apiCredentialsSet swaps credentials silently, no audit event#387
divybot wants to merge 1 commit into
mainfrom
orch/issue-85

Conversation

@divybot
Copy link
Copy Markdown
Contributor

@divybot divybot commented May 14, 2026

Closes example/orchestrator#85

PR #85 wired the CLI's `--profile` suggestion through `/api/onboard/start`
and `/api/onboard/approve`, but the gateway stored whatever string the
caller passed without checking it against the declared policy. A typo
or stray value reached `AssignProfile`, which records on the device row,
and runtime dispatch's `HostEndpoint` fallback then silently walks every
profile looking for the host — masking the typo as confusing routing
instead of failing fast.

Reject unknown profile names at both edges so the operator's intent
is honored or rejected, never silently rewritten:

- `apiOnboardStart`: 400 before the session is allocated. The dashboard
  approve page would otherwise show a code for a session whose suggested
  profile can never produce a working assignment.
- `apiOnboardApprove`: 400 for both the dashboard `?profile=` override
  and the CLI suggestion stashed on the session (catches the policy-
  reload race where a profile vanishes between start and approve).
- Empty profile is still fine; `defaultProfileName` handles the
  fallback chain (literal "default" → first declared → "").

The single check lives in a `profileExists(policy, name)` helper next
to `defaultProfileName`, and the existing assign-profile endpoint in
agents.go is refactored onto it (replacing an inline loop).

Surface the CLI-suggested profile (and hostname) on `/api/onboard/lookup`
so the approve page can show the operator what the CLI typed before
they click — previously this was stored server-side only.

Tests cover known/unknown profile at start and approve, the CLI-
suggestion-wins-when-dashboard-sends-nothing priority, the stale-after-
reload rejection, and the no-profile default fallback path.

Closes #320.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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