sec(api): restrict SourceIdentity to admin sessions in GET /api/config (closes #407) - #530
Conversation
|
Warning Review limit reached
More reviews will be available in 21 minutes and 57 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 (3)
📝 WalkthroughWalkthroughThe handler ChangesAdmin-only SourceIdentity for config endpoint
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
@coderabbitai full review |
Rate Limit Exceeded
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
closes #407) GET /api/config returned SourceIdentity (AWS account ID, Azure tenant ID / subscription ID, GCP project ID) to any authenticated user. Non-admin roles should not have access to the host cloud identity. Change getConfig to accept the request so it can call requireAdmin. Only populate SourceIdentity when the caller is an admin; non-admin responses get SourceIdentity: nil. SourceCloud (the cloud name string "aws"/"azure") is still returned to all authenticated users as it is needed by the dashboard for feature gating. Update all call sites (router wrapper, existing tests). Add regression tests confirming non-admin sessions receive a nil SourceIdentity.
…ionAPI for admin gate, assert SourceIdentity admin-only - Remove Session.Role field from all Session literals in handler_config_test.go (Role was removed in #907/#912; role-based short-circuit replaced by group membership via HasPermissionAPI) - Add mockAuth.grantAdmin() to TestHandler_getConfig so the admin permission check in requireAdmin is satisfied - Add explicit HasPermissionAPI stub for "admin-user" in TestHandler_getConfig_SourceIdentity_AdminOnly (required now that the admin path goes through HasPermissionAPI, not a Role field) - Replace no-op `_ = result.SourceIdentity` with require.NotNil assertion (admin sessions must receive SourceIdentity per issue #407) - Non-admin subtest already asserts SourceIdentity == nil via assert.Nil
1302b71 to
4141366
Compare
|
Fix commit summary (4141366): Gap 1 - Removed Session.Role fields: Dropped Gap 2 - HasPermissionAPI stubs for admin gate: Added Gap 3 - Assert the invariant: Replaced the no-op Verification: @coderabbitai review |
|
1461/1461 passing with a clean pre-commit run is a good signal. Triggering a fresh review now. 🧠 Learnings used✅ Action performedReview finished.
|
Summary
GET /api/configreturnedSourceIdentity(AWS account ID, Azure tenant ID/subscription ID, GCP project ID) to any authenticated user. Non-admin roles should not see the host cloud identity.getConfigto accept the request and callrequireAdmin. Only populateSourceIdentityfor admin sessions; non-admin responses getSourceIdentity: nil.SourceCloud(the plain string "aws"/"azure"/"gcp") is still returned to all authenticated users as it is needed for dashboard feature gating.nilSourceIdentity.Test plan
go test ./internal/api/... ./internal/auth/...passes (1572 tests)TestHandler_getConfig_SourceIdentity_AdminOnly/regression_#407assertsresult.SourceIdentity == nilfor non-adminCloses #407
Summary by CodeRabbit
Release Notes