🛡️ Sentinel: [CRITICAL] Fix missing authentication on admin endpoints - #188
🛡️ Sentinel: [CRITICAL] Fix missing authentication on admin endpoints#188seonghobae wants to merge 1 commit into
Conversation
- AdminController의 모든 엔드포인트에 인증 및 권한 확인 로직(TenantAccessService) 추가 - `ADMIN_READ`, `ADMIN_WRITE` 권한 요구되도록 수정 - 관련 테스트 코드 수정 및 100% 테스트 커버리지 유지 - `.jules/sentinel.md`에 보안 관련 지식 기록
|
👋 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 addresses a critical security gap by enforcing tenant-claim authentication and permission checks on AdminController endpoints, aligning admin routes with the rest of the API’s TenantAccessService-based access control model.
Changes:
- Inject
TenantAccessServiceintoAdminControllerand requireadmin:read/admin:writepermissions on admin endpoints. - Introduce new permission constants
ADMIN_READandADMIN_WRITEinTenantPermissions. - Update
AdminControllerTestto send tenant/auth headers on admin requests and document the incident in.jules/sentinel.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
src/main/java/com/clearfolio/viewer/controller/AdminController.java |
Adds header-based auth enforcement via TenantAccessService.require(...) on admin endpoints. |
src/main/java/com/clearfolio/viewer/auth/TenantPermissions.java |
Adds ADMIN_READ / ADMIN_WRITE permission constants used by the controller guard. |
src/test/java/com/clearfolio/viewer/controller/AdminControllerTest.java |
Adds auth headers to requests after controller signature change (but currently doesn’t assert guard enforcement). |
.jules/sentinel.md |
Records the “missing authentication on admin endpoints” vulnerability and prevention guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .uri("/api/v1/admin/convert/jobs") | ||
| .headers(AdminControllerTest::addAuth) | ||
| .exchange() |
| webTestClient.get() | ||
| .uri("/api/v1/admin/convert/jobs?deadLettered=true") | ||
| .headers(AdminControllerTest::addAuth) | ||
| .exchange() |
| webTestClient.get() | ||
| .uri("/api/v1/admin/convert/jobs?deadLettered=false") | ||
| .headers(AdminControllerTest::addAuth) | ||
| .exchange() |
| webTestClient.delete() | ||
| .uri("/api/v1/admin/convert/jobs/" + jobId) | ||
| .headers(AdminControllerTest::addAuth) | ||
| .exchange() | ||
| .expectStatus().isNoContent(); | ||
| } |
| webTestClient.post() | ||
| .uri("/api/v1/admin/convert/jobs/" + jobId + "/retry") | ||
| .headers(AdminControllerTest::addAuth) | ||
| .exchange() | ||
| .expectStatus().isAccepted(); | ||
| } |
| webTestClient.post() | ||
| .uri("/api/v1/admin/convert/jobs/" + jobId + "/retry") | ||
| .headers(AdminControllerTest::addAuth) | ||
| .exchange() | ||
| .expectStatus().isNotFound(); | ||
| } |
| webTestClient.post() | ||
| .uri("/api/v1/admin/convert/jobs/" + jobId + "/retry") | ||
| .headers(AdminControllerTest::addAuth) | ||
| .exchange() | ||
| .expectStatus().isEqualTo(409); // isConflict() isn't always available depending on spring-test version, so using isEqualTo(409) is safer | ||
| } |
Superseded by #172, the canonical admin authorization PR. #172 applies separate read/write permissions to all admin endpoints and has successful exact-head CI and security checks.