Skip to content

sec(api): gate GET /api/config and testAccountCredentials on correct permission verbs - #1068

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/api-config-perms
Jun 7, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/api-config-perms

Conversation

@cristim

@cristim cristim commented Jun 7, 2026

Copy link
Copy Markdown
Member

Summary

  • 02-M4: Added requirePermission(ctx, req, "view", "config") to getConfig and getServiceConfig in handler_config.go. These were the only read handlers in internal/api/ that lacked an explicit permission verb check, meaning a role with view:config revoked could still read app configuration. Threaded req through getServiceConfig's signature and updated getServiceConfigHandler in router.go to pass it.
  • 02-M5: Changed testAccountCredentials permission gate from view:accounts to update:accounts to match the handler's write-class side effect (live credential probing). The route is AuthAdmin, so current behaviour is unchanged; this makes the handler self-protecting if route auth is ever relaxed.

Verification

  • go build ./internal/api/... passes.
  • go vet ./internal/api/... passes.
  • go test ./internal/api/... passes (1495 tests).
  • Regression tests added:
    • TestHandler_getConfig_ViewConfigPermission_Enforced: asserts 403 when view:config is revoked on GET /api/config.
    • TestHandler_getServiceConfig_ViewConfigPermission_Enforced: asserts 403 when view:config is revoked on GET /api/config/service/*.
    • TestTestAccountCredentials_RequiresUpdateAccounts: asserts 403 when caller has view:accounts but not update:accounts on POST /api/accounts/:id/test.
  • No live Postgres available; all DB paths covered by pgxmock/mock pattern consistent with the package's existing test approach.

Closes #1053

…permission verbs (closes #1053)

02-M4: getConfig and getServiceConfig lacked a requirePermission("view","config")
call, relying solely on the router's AuthUser gate. A user whose view:config
permission was revoked could still read global and per-service configuration.
Add requirePermission("view","config") to both handlers; thread req through
getServiceConfig's signature and update getServiceConfigHandler in router.go.
Update existing tests to supply auth and add two regression tests that assert
403 when view:config is denied.

02-M5: testAccountCredentials probes live cloud credentials (write-class side
effect) but gated on view:accounts. The route is AuthAdmin, so the wrong verb
is currently dead, but a future route-auth relaxation would expose the handler
to view-only callers. Change to update:accounts and add a regression test.
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/few Limited audience effort/s Hours type/security Security finding labels Jun 7, 2026
@coderabbitai

coderabbitai Bot commented Jun 7, 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 4 minutes and 52 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: 38c07029-66c5-4938-95a7-d30028cc421b

📥 Commits

Reviewing files that changed from the base of the PR and between cbdc4be and 0a4a0f1.

📒 Files selected for processing (5)
  • internal/api/handler_accounts.go
  • internal/api/handler_accounts_test.go
  • internal/api/handler_config.go
  • internal/api/handler_config_test.go
  • internal/api/router.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/api-config-perms

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

@cristim

cristim commented Jun 7, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 7, 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 merged commit f74745e into feat/multicloud-web-frontend Jun 7, 2026
4 checks passed
@cristim
cristim deleted the fix/api-config-perms branch July 27, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/security Security finding urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant