Skip to content

fix(accounts): least-privilege accounts list for standard-user filter + plan prefill (closes #949, closes #951) - #987

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/standard-user-account-access
Jun 5, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/standard-user-account-access

Conversation

@cristim

@cristim cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the Standard / Read-Only user account-access cluster (QA rows 547, 548, 550, 551). closes #949, closes #951.

Unified root cause: Standard / Read-Only groups lack view:accounts, so GET /api/accounts 403s for them, which broke two things:

Approach (option a, least-privilege)

Add a minimal-disclosure accounts source these users CAN call, without exposing sensitive account config (no role ARNs, subscription IDs, client emails, auth modes, or the self-account marker).

Backend

  • New endpoint GET /api/accounts/list returning the minimal projection [{id, name, external_id, provider}], gated in-handler on view:recommendations (held by both Standard Users and Read-Only Users groups) rather than the admin-grade view:accounts. Scoped by allowed_accounts exactly like the full list. The full CloudAccount object (role ARNs, subscription IDs, client emails) stays behind view:accounts on GET /api/accounts.
  • Route registered as an exact path before the generic /api/accounts/ GET prefix so "list" is not mistaken for an account :id.

Frontend

Row 550 banner

Endpoint authz

Endpoint Verb gate Standard user Returns
GET /api/accounts/list (new) view:recommendations allowed minimal {id, name, external_id, provider}, scoped
GET /api/accounts (unchanged) view:accounts 403 full account config (admin-grade)

Tests

  • Backend (internal/api/handler_accounts_test.go, ..._router_test.go): standard user allowed; full-list view:accounts user still 403s; no view:recommendations -> 403; allowed_accounts scoping; the JSON projection contains no sensitive fields; router dispatches /api/accounts/list to the minimal handler (not getAccount).
  • Frontend: standard-user topbar dropdown populates from the minimal endpoint; plan modal prefills the target via the minimal list; save-failure shows an error toast AND keeps the modal open; row-550 banner copy assertions.

Verification

  • gofmt -l clean, go vet ./internal/... clean, go build ./... OK.
  • go test ./internal/api/ -> 1464 passed.
  • npx tsc --noEmit clean; npx jest -> 2350 passed, 0 failed.
  • SKIP=terraform_validate pre-commit run --all-files -> all passed (incl. the Go-defaults frontend-permissions regen, which made no changes).

… + plan prefill (closes #949, closes #951)

Standard / Read-Only user groups lack view:accounts, so GET /api/accounts
403s for them. This broke two flows: the global filter Account dropdown
showed only "All Accounts" (#951, row 551), and the create-plan-from-
commitment Target Account could not be pre-filled (the per-id account
fetch 403'd), so Save Plan silently no-opped behind the empty-target
guard with no error (#949, rows 547/548).

Add a minimal-disclosure source these users CAN call, without exposing
sensitive account config:

- New GET /api/accounts/list returns [{id, name, external_id, provider}]
  gated on view:recommendations (held by both Standard and Read-Only
  groups), scoped by allowed_accounts. The full CloudAccount object
  (role ARNs, subscription IDs, client emails, auth modes) stays behind
  view:accounts on GET /api/accounts.
- Wire the topbar filter dropdown, the plan-account search, and the
  commitment-target prefill to listAccountsMinimal.

Row 550 banner: correct the nav name ("Settings" -> "Admin", renamed in
#340) and scope the message to execute-purchases only, since standard
users CAN create and manage plans. Same fix applied to the identical
history banner.

Tests:
- backend: authz contract for /api/accounts/list (standard user allowed,
  view:accounts user still 403s on the full list, no view:recommendations
  -> 403, allowed_accounts scoping, no sensitive fields in the projection,
  router dispatch precedence over the generic prefix route).
- frontend: standard-user dropdown populates from the minimal endpoint;
  plan modal prefills target via the minimal list; save-failure shows an
  error toast AND keeps the modal open; banner copy assertions for row 550.
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/many Affects most users type/bug Defect labels Jun 5, 2026
@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 33 minutes and 30 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9601f7a-8997-4482-accc-2b4d3e308e07

📥 Commits

Reviewing files that changed from the base of the PR and between 55739c2 and 8f0b975.

📒 Files selected for processing (15)
  • frontend/src/__tests__/allowed-accounts.test.ts
  • frontend/src/__tests__/api-accounts.test.ts
  • frontend/src/__tests__/plans.test.ts
  • frontend/src/__tests__/recommendations-permissions.test.ts
  • frontend/src/__tests__/topbar-filters.test.ts
  • frontend/src/api/accounts.ts
  • frontend/src/api/index.ts
  • frontend/src/history.ts
  • frontend/src/plans.ts
  • frontend/src/recommendations.ts
  • frontend/src/topbar-filters.ts
  • internal/api/handler_accounts.go
  • internal/api/handler_accounts_router_test.go
  • internal/api/handler_accounts_test.go
  • internal/api/router.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/standard-user-account-access

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim

cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

1 similar comment
@cristim

cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@cristim
cristim merged commit 8ab0d20 into feat/multicloud-web-frontend Jun 5, 2026
5 checks passed
@cristim
cristim deleted the fix/standard-user-account-access branch June 5, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact/many Affects most users priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant