[P1] F-9: apiCredentialsSet swaps credentials silently, no audit event#387
Open
divybot wants to merge 1 commit into
Open
[P1] F-9: apiCredentialsSet swaps credentials silently, no audit event#387divybot wants to merge 1 commit into
divybot wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes example/orchestrator#85