[Feat] PermissionQueryService 구현 - 문서 접근 권한 5단계 판단 로직 - #23
Conversation
- UserDocumentAccessCacheRepository: existsValidRead/Write/AdminCache - DocumentPermissionRepository: ROLE/DEPT live predicate (Read/Write/Admin) - CollectionPermissionRepository: ROLE/DEPT live predicate + 컬렉션 USER 권한 조회 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- canReadDocument/canWriteDocument/canAdminDocument: owner→PUBLIC→USER캐시→ROLE live→DEPT live 순 판단 - canWriteCollection/canAdminCollection: 소유자 또는 USER 직접 권한 - 각 단계 소요 시간 타이밍 로그 추가 (포트폴리오용) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- DocumentPermissionCommandService: canAdminDocument() 적용 (grant/revoke) - CollectionPermissionCommandService: canAdminCollection() 적용 (grant/revoke) - CollectionCommandService: canWriteCollection() 적용 (addDocument) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- PermissionQueryServiceTest: 5단계 판단 로직 검증 (9개 테스트) - CollectionCommandServiceTest/CollectionPermissionCommandServiceTest/DocumentPermissionCommandServiceTest: PermissionQueryService Mock 추가 및 stub 업데이트 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. 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, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough문서·컬렉션 권한 판정 서비스와 캐시·역할·부서 기반 조회 쿼리를 추가했습니다. 문서 추가 및 권한 부여·회수 명령은 소유자 비교 대신 통합 권한 서비스를 사용하며, 관련 단위 테스트가 보강되었습니다. Changes권한 판정 흐름
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CommandService
participant PermissionQueryService
participant Repositories
CommandService->>PermissionQueryService: 권한 판정 요청
PermissionQueryService->>Repositories: 문서·컬렉션·캐시 권한 조회
Repositories-->>PermissionQueryService: 권한 존재 여부 반환
PermissionQueryService-->>CommandService: 허용 또는 PERMISSION_DENIED
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 4
🤖 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.
Inline comments:
In
`@src/main/java/com/opensource/docgrid/domain/permission/repository/CollectionPermissionRepository.java`:
- Around line 89-98: Update the comment above existsUserWritePermission to
reference canWriteCollection rather than canAdminCollection, keeping the query
and method implementation unchanged.
In
`@src/main/java/com/opensource/docgrid/domain/permission/service/query/PermissionQueryService.java`:
- Around line 164-178: 컬렉션 권한 판단이 USER 대상 권한만 확인하므로 ROLE 및 DEPARTMENT 권한도 누락 없이
평가하도록 수정하세요. canWriteCollection과 canAdminCollection에서 기존 소유자 허용 및 USER 검사 흐름은
유지하되, 문서 권한 검증 흐름에서 사용하는 그룹 권한 확인 로직을 재사용하여 해당 사용자의 ROLE/DEPARTMENT 기반 쓰기·관리 권한도
함께 허용하세요.
- Around line 32-82: Update the telemetry calculations in
PermissionQueryService.canReadDocument
(src/main/java/com/opensource/docgrid/domain/permission/service/query/PermissionQueryService.java:32-82),
canWriteDocument (same file:84-122), and canAdminDocument (same file:124-162) to
compute each step’s duration from timestamps captured at that step’s boundary,
before subsequent queries execute. Replace delayed ms(t_prev) evaluations with
fixed elapsed values derived from the current and previous timestamps, while
preserving the existing log fields and authorization behavior.
In
`@src/test/java/com/opensource/docgrid/domain/permission/service/query/PermissionQueryServiceTest.java`:
- Around line 149-193: Add tests in PermissionQueryServiceTest covering
canWriteDocument and canAdminDocument owner, cache, role, department, and false
branches, plus canWriteCollection owner, USER-permission, and false branches.
Reuse the existing fixtures, mocks, and assertion style, and verify the expected
repository interactions where applicable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8b4194e7-3e43-42f7-9530-b1f8e32dd470
📒 Files selected for processing (11)
src/main/java/com/opensource/docgrid/domain/collection/service/command/CollectionCommandService.javasrc/main/java/com/opensource/docgrid/domain/permission/repository/CollectionPermissionRepository.javasrc/main/java/com/opensource/docgrid/domain/permission/repository/DocumentPermissionRepository.javasrc/main/java/com/opensource/docgrid/domain/permission/repository/UserDocumentAccessCacheRepository.javasrc/main/java/com/opensource/docgrid/domain/permission/service/command/CollectionPermissionCommandService.javasrc/main/java/com/opensource/docgrid/domain/permission/service/command/DocumentPermissionCommandService.javasrc/main/java/com/opensource/docgrid/domain/permission/service/query/PermissionQueryService.javasrc/test/java/com/opensource/docgrid/domain/collection/service/command/CollectionCommandServiceTest.javasrc/test/java/com/opensource/docgrid/domain/permission/service/command/CollectionPermissionCommandServiceTest.javasrc/test/java/com/opensource/docgrid/domain/permission/service/command/DocumentPermissionCommandServiceTest.javasrc/test/java/com/opensource/docgrid/domain/permission/service/query/PermissionQueryServiceTest.java
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ment·canWriteCollection·canAdminCollection ROLE/DEPT 경로) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔍 작업 내용
✨ 상세 설명
PermissionQueryService 구현
문서 접근 권한을 5단계로 판단하는 핵심 서비스 구현
판단 순서 (성능 순)
user_document_access_cache에 유효한 row 존재 시 허용앞 단계에서 허용되면 뒤 단계는 실행하지 않음. 각 단계 소요 시간 타이밍 로그 기록.
컬렉션 레벨 권한 추가
canWriteCollection/canAdminCollection— 소유자 또는 USER 직접 권한TODO 교체 (3곳)
owner 직접 비교 → PermissionQueryService 호출로 교체
DocumentPermissionCommandService:canAdminDocument()적용CollectionPermissionCommandService:canAdminCollection()적용CollectionCommandService:canWriteCollection()적용🛠️ 추후 리팩토링 및 고도화 계획
GET /permissions/documents/{documentId}/me구현 시canReadDocument호출 및 타이밍 로그 확인 가능💬 리뷰 요구사항
canReadDocument5단계 판단 순서 및 단락 조건 확인 부탁Summary by CodeRabbit
새로운 기능
개선 사항
테스트