🛡️ Sentinel: [CRITICAL] 관리자 엔드포인트에 인증 추가 - #193
Conversation
관리자 엔드포인트(`AdminController`)에 적절한 인증 및 권한 확인이 부족하여, 인증되지 않은 사용자가 모든 변환 작업을 읽거나 삭제하고 재시도할 수 있는 보안 취약점이 있었습니다. TenantAccessService를 주입하고 모든 엔드포인트(getAllJobs, deleteJob, retryDeadLettered)에서 `tenantAccessService.require(...)`를 호출하여 적절한 권한(`ADMIN_READ`, `ADMIN_WRITE`)이 있는지 확인하도록 수정했습니다. `TenantPermissions` 클래스에 관련 상수도 추가했습니다. 관련된 테스트도 모의 컨텍스트를 제공하도록 업데이트했습니다.
|
👋 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 endpoints by enforcing tenant-based authentication and explicit admin permissions, aligning /api/v1/admin/** operations with the existing TenantAccessService security model used elsewhere in the viewer backend.
Changes:
- Inject
TenantAccessServiceintoAdminControllerand requireADMIN_READ/ADMIN_WRITEpermissions on admin endpoints. - Introduce
TenantPermissions.ADMIN_READandTenantPermissions.ADMIN_WRITE. - Update
AdminControllerTestto accommodate the new controller dependency and request header expectations; add a Sentinel log entry for the incident.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/main/java/com/clearfolio/viewer/controller/AdminController.java | Adds tenant/permission enforcement to admin endpoints via TenantAccessService.require(...). |
| src/test/java/com/clearfolio/viewer/controller/AdminControllerTest.java | Updates tests for new controller constructor + request headers; currently mocks auth. |
| src/main/java/com/clearfolio/viewer/auth/TenantPermissions.java | Adds ADMIN_READ / ADMIN_WRITE permission constants. |
| .jules/sentinel.md | Records the security learning/prevention note for the fixed admin-auth issue (currently duplicated). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ## 2026-07-22 - Missing Authentication on Admin Endpoints | ||
| **Vulnerability:** The `AdminController` endpoints (`/api/v1/admin/convert/jobs`, `/api/v1/admin/convert/jobs/{jobId}`, `/api/v1/admin/convert/jobs/{jobId}/retry`) lacked authentication and authorization checks, allowing unauthenticated users to read, delete, and retry all conversion jobs. | ||
| **Learning:** Spring controllers must explicitly enforce security policies, even if they are placed under an `/admin` path. The existence of an admin path does not automatically protect it. | ||
| **Prevention:** Always inject `TenantAccessService` and invoke `tenantAccessService.require(...)` for every controller method to ensure permissions are checked before processing the request. Add corresponding unit tests that explicitly check for these authorization controls. |
| webTestClient = WebTestClient.bindToController(controller) | ||
| .controllerAdvice(new ApiExceptionHandler()) | ||
| .build(); | ||
| when(tenantAccessService.require(any(), any())).thenReturn(new TenantContext("t1", "s1", Set.of("admin:read", "admin:write"))); |
| controller = new AdminController(conversionService, tenantAccessService); | ||
| webTestClient = WebTestClient.bindToController(controller) | ||
| .controllerAdvice(new ApiExceptionHandler()) | ||
| .build(); | ||
| when(tenantAccessService.require(any(), any())).thenReturn(new TenantContext("t1", "s1", Set.of("admin:read", "admin:write"))); |
| @@ -43,7 +50,8 @@ public AdminController(DocumentConversionService conversionService) { | |||
| * @return list of conversion jobs | |||
Superseded by #172, which already implements and verifies the same
ADMIN_READ/ADMIN_WRITEauthorization controls. Closing this duplicate prevents parallel security patches from diverging.