docs(api): document 403 on permission-gated routes#884
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
#660) RI exchanges are financially irreversible once submitted to AWS. Keeping execute:ri-exchange disjoint from execute:purchases ensures a user who can initiate regular purchases cannot inadvertently — or intentionally — trigger an RI exchange without an explicit additional grant. Changes: - Add ResourceRIExchange = "ri-exchange" constant to internal/auth/types.go - Update executeExchange handler to require execute:ri-exchange (was execute:purchases) - Update TestExecuteExchange_PermissionGate to assert the new permission verb; add isolation sub-test proving execute:purchases does not grant ri-exchange access - Add /api/ri-exchange/* routes to openapi.yaml with 403 responses and permission documentation on the execute endpoint - Add 'ri-exchange' to the frontend Resource closed-union type and extend canAccess tests: admin true, user false (no default grant) No DB migration needed: role defaults are computed at runtime from Go constants; no DB table stores the permission set. No conflict with PR #884 (fix/476): that PR adds 403 to plans/purchases routes; this PR adds a new ri-exchange section that #884 does not touch.
#660) RI exchanges are financially irreversible once submitted to AWS. Keeping execute:ri-exchange disjoint from execute:purchases ensures a user who can initiate regular purchases cannot inadvertently (or intentionally) trigger an RI exchange without an explicit additional grant. Changes: - Add ResourceRIExchange = "ri-exchange" constant to internal/auth/types.go - Update executeExchange handler to require execute:ri-exchange (was execute:purchases) - Update TestExecuteExchange_PermissionGate to assert the new permission verb; add isolation sub-test proving execute:purchases does not grant ri-exchange access - Add /api/ri-exchange/* routes to openapi.yaml with 403 responses and permission documentation on the execute endpoint - Add 'ri-exchange' to the frontend Resource closed-union type and extend canAccess tests: admin true, user false (no default grant); add isolation sub-tests proving execute:purchases does not imply execute:ri-exchange (and vice versa) on the frontend gating mirror Rebased onto feat/multicloud-web-frontend post #922 (effectivePermissions migration). The conflict in frontend/src/__tests__/permissions.test.ts was resolved by re-expressing the user-default-deny invariant in the new effective-permissions model: a non-admin holding execute:purchases is still denied execute:ri-exchange. Em-dashes scrubbed from added prose. No DB migration needed: role defaults are computed at runtime from Go constants; no DB table stores the permission set. No conflict with PR #884 (fix/476): that PR adds 403 to plans/purchases routes; this PR adds a new ri-exchange section that #884 does not touch.
#660) (#891) RI exchanges are financially irreversible once submitted to AWS. Keeping execute:ri-exchange disjoint from execute:purchases ensures a user who can initiate regular purchases cannot inadvertently (or intentionally) trigger an RI exchange without an explicit additional grant. Changes: - Add ResourceRIExchange = "ri-exchange" constant to internal/auth/types.go - Update executeExchange handler to require execute:ri-exchange (was execute:purchases) - Update TestExecuteExchange_PermissionGate to assert the new permission verb; add isolation sub-test proving execute:purchases does not grant ri-exchange access - Add /api/ri-exchange/* routes to openapi.yaml with 403 responses and permission documentation on the execute endpoint - Add 'ri-exchange' to the frontend Resource closed-union type and extend canAccess tests: admin true, user false (no default grant); add isolation sub-tests proving execute:purchases does not imply execute:ri-exchange (and vice versa) on the frontend gating mirror Rebased onto feat/multicloud-web-frontend post #922 (effectivePermissions migration). The conflict in frontend/src/__tests__/permissions.test.ts was resolved by re-expressing the user-default-deny invariant in the new effective-permissions model: a non-admin holding execute:purchases is still denied execute:ri-exchange. Em-dashes scrubbed from added prose. No DB migration needed: role defaults are computed at runtime from Go constants; no DB table stores the permission set. No conflict with PR #884 (fix/476): that PR adds 403 to plans/purchases routes; this PR adds a new ri-exchange section that #884 does not touch.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
cr-watch-884 summary: CodeRabbit returned no actionable findings on this PR.
No code changes required; closing the watcher. Ready for human merge. |
Rate Limit Exceeded
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Every operation in openapi.yaml whose handler calls requirePermission now declares '403: $ref: "#/components/responses/Forbidden"' alongside the existing 401. 27 operations updated across dashboard, config, recommendations, plans, planned-purchases, purchases, history, and api-keys sections. The components/responses/Forbidden component already existed (used in the users/groups section); this change wires it consistently across all remaining permission-gated routes. Adds openapi_403_test.go: a source-reading regression guard that walks router.go to map each route's handler wrapper to its delegate h.* function, then checks whether that function calls requirePermission, and asserts the spec operation declares 403. The test fails as soon as a new permission-gated route is wired in router.go without a matching 403 in the spec.
…ice/{service}
Both handlers call requirePermission("view","config") but the spec only
declared 403 on their PUT counterparts. The regression test added in this
PR caught the gap. Add the missing 403 response to both GET operations.
Closes #476
Summary
403: $ref: '#/components/responses/Forbidden'to 27 operations ininternal/api/openapi.yamlwhose handlers callrequirePermission()but previously only declared401components/responses/Forbiddencomponent (already present in users/groups section)internal/api/openapi_403_test.go: a source-reading regression guard that walks router.go to resolve each route's delegate handler, checks whether it callsrequirePermission, and asserts the spec operation declares 403 -- the test fails immediately when a new permission-gated route is added without the matching 403Test plan
go test ./internal/api/ -run TestOpenAPI403OnPermissionGatedRoutespassesgo test ./internal/api/...passes (1356 tests)requirePermissionwithout a 403 in the spec and confirm the test fails