🛡️ Sentinel: [CRITICAL] Add authorization checks to AdminController - #201
🛡️ Sentinel: [CRITICAL] Add authorization checks to AdminController#201seonghobae wants to merge 1 commit into
Conversation
This commit addresses a critical security vulnerability where the administrative API endpoints (`getAllJobs`, `deleteJob`, `retryDeadLettered`) lacked proper tenant-based authorization. The `AdminController` was updated to require explicit `ADMIN_READ` or `ADMIN_WRITE` permissions by injecting the `TenantAccessService` and asserting these required permissions using the provided request headers. Unit tests were updated to include these mocked services and dummy headers to maintain 100% test coverage and ensure future stability.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR hardens Clearfolio’s admin conversion-job endpoints by enforcing tenant-claim authentication and explicit admin permissions via TenantAccessService, reducing the risk of unauthorized cross-tenant job access/mutation.
Changes:
- Enforced
ADMIN_READ/ADMIN_WRITEpermission checks onAdminControllerendpoints using request headers. - Added
admin:readandadmin:writepermission constants toTenantPermissions. - Updated
AdminControllerTestscaffolding for the new controller signature and added request headers in test calls; documented the learning in.jules/sentinel.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/java/com/clearfolio/viewer/controller/AdminController.java | Adds TenantAccessService enforcement for admin read/write endpoints. |
| src/main/java/com/clearfolio/viewer/auth/TenantPermissions.java | Introduces new admin permission constants used by the controller. |
| src/test/java/com/clearfolio/viewer/controller/AdminControllerTest.java | Updates controller construction and request setup for new auth checks. |
| .jules/sentinel.md | Records the security learning entry for this vulnerability class. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import java.util.Arrays; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.ArgumentMatchers.eq; |
| tenantAccessService.require(headers, com.clearfolio.viewer.auth.TenantPermissions.ADMIN_WRITE); | ||
| RetryDeadLetterResult result = conversionService.retryDeadLettered(jobId, "admin"); |
| TenantContext dummyContext = new TenantContext("test-tenant", "test-subject", java.util.Set.of()); | ||
| when(tenantAccessService.require(any(), eq(TenantPermissions.ADMIN_READ))).thenReturn(dummyContext); | ||
| when(tenantAccessService.require(any(), eq(TenantPermissions.ADMIN_WRITE))).thenReturn(dummyContext); |
Superseded by #172, the canonical admin authorization change. #172 enforces separate read/write permissions on all admin operations and has successful current-head validation.