[FEAT/#359] 백오피스 권한 처리 및 Security 세팅#360
Merged
Merged
Conversation
…fice/**, /admin/**, /partner/**), permitAll 정리
…m/ASSU-org/ASSU_BE into feat/#359-admin-api-authorization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#️⃣연관된 이슈
📝작업 내용
요약
플랫폼 운영자(
BACKOFFICE) 역할 추가전용 로그인 추가
/backoffice/**API 추가백오피스 전용 감사 로그를 수집하기 위해 AOP 패턴 작성
기존 API에
@PreAuthorizeRBAC를 일괄 적용하여 권한 분리 명확히함A. 빌드 · 테스트 설정
build.gradlespring-boot-starter-aop추가 →@PreAuthorize+@BackofficeAuditedAspect 동작application-test.ymlbackoffice.bootstrap.enabled=false등B. 역할 · 엔티티 (데이터 모델)
UserRole.javaBACKOFFICEenum 추가Member.javabackofficeProfile1:1 연관 추가BackofficeUser.javaname)BackofficeUserRepository.javaBackofficeAuditLog.javaBackofficeAuditStatus.javaSUCCESS/FAILUREC. 백오피스 전용 인증
BackofficeAuthController.javaPOST /auth/backoffice/login,/auth/backoffice/tokens/refreshBackofficeAuthService.javaBackofficeAuthServiceImpl.javaBACKOFFICE만 허용,aud=backofficeJWT 발급 / refresh 시 aud 검증BackofficeLoginResponseDTO.javaUserBasicInfoDTO.javaBACKOFFICEcase — 이름만 매핑LoginServiceImpl.javaCommonAuthAdapter.javaregisterCredentials후member.setCommonAuth()(bootstrap NPE 수정)JwtUtil.javaAUD_APP/AUD_BACKOFFICE,issueBackofficeTokens,assertAudience, refresh aud 유지JwtAuthFilter.javaCustomAuthException재전파흐름: 앱 JWT(
aud=app) ↔ 백오피스 JWT(aud=backoffice) 상호 사용 불가.D. Bootstrap · 운영자 관리
BackofficeBootstrapInitializer.javabackoffice.bootstrap.enabled=true+ DB 0명일 때@Value로 최초 운영자 1명 생성BackofficeOperatorController.javaPOST/GET /backoffice/operatorsBackofficeOperatorService.javaBackofficeOperatorServiceImpl.javaBackofficeOperatorCreateRequestDTO.javaBackofficeOperatorResponseDTO.javaE. 백오피스 운영 API (기존 API 이전)
BackofficeStudentController.javaPOST /backoffice/students/sync(구/students/sync/all이전)BackofficeInquiryController.javaPATCH /backoffice/inquiries/{id}/answer(구 inquiry answer 이전)둘 다
@PreAuthorize("hasRole('BACKOFFICE')")+ mutating API에@BackofficeAudited.F. 감사 로그 (AOP)
BackofficeAudited.javaaction,targetId(SpEL) 마커 어노테이션BackofficeAuditAspect.javaBackofficeAuditLogRepository.javaBackofficeAuditLogService.javaREQUIRES_NEW로 API rollback과 분리 저장새 mutating API 추가 시:
@BackofficeAudited(action = "...")만 붙이면 됨.G. 전역 Security · RBAC 인프라
MethodSecurityConfig.java@EnableMethodSecuritySecurityConfig.java/backoffice/**→BACKOFFICE,/admin/**→ADMIN,/partner/**→PARTNER; backoffice login permitAll; EntryPoint/AccessDeniedHandler 등록RestAuthenticationEntryPoint.javaBaseResponse401RestAccessDeniedHandler.javaBaseResponse403SecurityErrorResponseWriter.javaGlobalExceptionAdvice.javaAccessDeniedException→ 403 BaseResponseErrorStatus.javaNO_BACKOFFICE_TYPE,JWT_AUDIENCE_MISMATCH,BACKOFFICE_USE_DEDICATED_LOGIN,LAST_BACKOFFICE_OPERATOR등H. 기존 컨트롤러 —
@PreAuthorize적용역할별 URL 접근 + 메서드 단위 이중 방어. 비즈니스 로직 변경 없음, 권한만 추가.
AdminController.java@PreAuthorize("hasRole('ADMIN')")StudentAdminController.java@PreAuthorize("hasRole('ADMIN')")PartnerController.java@PreAuthorize("hasRole('PARTNER')")StudentController.java@PreAuthorize("hasRole('STUDENT')")(+ sync endpoint 제거)InquiryController.java@PreAuthorize("hasRole('STUDENTS')")SuggestionController.javaSTUDENT|ADMIN, 메서드별 분기StoreController.javaSTUDENT|ADMIN|BACKOFFICE, papers는STUDENT, ranking은PARTNERMapController.java@PreAuthorize("hasAnyRole('STUDENT','ADMIN','PARTNER')")PartnershipController.javaMemberController.javaSTUDENT|ADMIN|PARTNERNotificationController.javaSTUDENT|ADMIN|PARTNERChatController.javaADMIN|PARTNERReviewController.javaReportController.javaSTUDENT|ADMIN|PARTNERDeviceTokenController.javaSTUDENT|ADMIN|PARTNERCertificationController.java@PreAuthorize("hasRole('STUDENT')")GroupCertificationController.java@PreAuthorize("hasRole('STUDENT')")AppReviewController.java@PreAuthorize("hasRole('STUDENT')")TemporaryQrController.java@PreAuthorize("hasRole('STUDENT')")RedirectController.java@PreAuthorize("hasRole('STUDENT')")I. Partnership ownership (보안 구멍 수정)
PartnershipService.javaPartnershipServiceImpl.javaassertPaperAccess()— ADMIN/PARTNER가 본인 paper만 get/update/delete역할만 맞고 남의 리소스 접근하던 케이스 차단.
J. BACKOFFICE 추가 부수 수정
NotificationCommandServiceImpl.javaswitch(role)에BACKOFFICE→ 알림 타입 없음NotificationQueryServiceImpl.javaUserRoleexhaustive switch 컴파일 대응.K. 테스트
BackofficeSecurityIntegrationTest.javaBackofficeAuditAspectTest.java기능별 파일 묶음 (역방향)
기타 변경사항
POST /students/sync/allPOST /backoffice/students/sync(BACKOFFICE JWT)PATCH /inquiries/{id}/answer(앱)PATCH /backoffice/inquiries/{id}/answer/auth/backoffice/loginonly/backoffice,/admin,/partnerprefix RBAC🔎코드 설명(스크린샷(선택))
💬고민사항 및 리뷰 요구사항 (Optional)
비고 (Optional)