Repository navigation
sec(api): gate GET /api/config and testAccountCredentials on correct permission verbs - #1068
Conversation
…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.
|
Warning Review limit reached
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
requirePermission(ctx, req, "view", "config")togetConfigandgetServiceConfiginhandler_config.go. These were the only read handlers ininternal/api/that lacked an explicit permission verb check, meaning a role withview:configrevoked could still read app configuration. ThreadedreqthroughgetServiceConfig's signature and updatedgetServiceConfigHandlerinrouter.goto pass it.testAccountCredentialspermission gate fromview:accountstoupdate:accountsto match the handler's write-class side effect (live credential probing). The route isAuthAdmin, 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).TestHandler_getConfig_ViewConfigPermission_Enforced: asserts 403 whenview:configis revoked onGET /api/config.TestHandler_getServiceConfig_ViewConfigPermission_Enforced: asserts 403 whenview:configis revoked onGET /api/config/service/*.TestTestAccountCredentials_RequiresUpdateAccounts: asserts 403 when caller hasview:accountsbut notupdate:accountsonPOST /api/accounts/:id/test.Closes #1053