Add compact auth check for staff privilege history endpoint#1669
Add compact auth check for staff privilege history endpoint#1669landonshumway-ia wants to merge 4 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 58 minutes and 44 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?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 credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. 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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe staff privilege-history endpoint lacked compact-level authorization, enabling cross-compact IDOR. This fix adds ChangesStaff privilege-history compact authorization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
backend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_privilege_history.py (1)
129-139: 💤 Low valueTest method name could more precisely reflect the 403 response.
The test asserts
403(access denied/forbidden) but the name uses "unauthorized" which typically refers to401. Consider renaming totest_staff_privilege_history_returns_forbidden_if_user_not_in_same_compactfor semantic precision. This is purely a naming nitpick—the test logic correctly validates the IDOR fix.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_privilege_history.py` around lines 129 - 139, The test method name `test_staff_privilege_history_returns_unauthorized_if_user_not_in_same_compact` uses "unauthorized" which typically corresponds to HTTP 401, but the test validates a 403 status code which is "forbidden". Rename the test method to `test_staff_privilege_history_returns_forbidden_if_user_not_in_same_compact` to accurately reflect the HTTP status code being asserted in the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@backend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_privilege_history.py`:
- Around line 129-139: The test method name
`test_staff_privilege_history_returns_unauthorized_if_user_not_in_same_compact`
uses "unauthorized" which typically corresponds to HTTP 401, but the test
validates a 403 status code which is "forbidden". Rename the test method to
`test_staff_privilege_history_returns_forbidden_if_user_not_in_same_compact` to
accurately reflect the HTTP status code being asserted in the test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9cf38d30-c419-443e-82d7-1bb6adcf29ec
📒 Files selected for processing (2)
backend/compact-connect/lambdas/python/provider-data-v1/handlers/privilege_history.pybackend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_privilege_history.py
|
@jlkravitz This is now ready for your review. Thanks |
jlkravitz
left a comment
There was a problem hiding this comment.
@isabeleliassen This is good to merge!
This adds an auth check to verify that the staff user caller has the read general permissions for the compact they are
attempting to request information for. This endpoint is gated by a Cognito authorizer that verifies the caller has the
readGeneral scope for any of the compacts. This further narrows that check to ensure the scope is specific to the compact in the path parameter.
Testing List
yarn test:unit:allshould run without errors or warningsyarn serveshould run without errors or warningsyarn buildshould run without errors or warningsbackend/compact-connect/tests/unit/test_api.pyrun compact-connect/bin/download_oas30.pyCloses #1659
Summary by CodeRabbit
Bug Fixes
Tests