Skip to content

feat: [HYJ] role 수정#105

Merged
rlaalsdn0421 merged 4 commits into
developfrom
dev/jun
Apr 30, 2026
Merged

feat: [HYJ] role 수정#105
rlaalsdn0421 merged 4 commits into
developfrom
dev/jun

Conversation

@HaJunyoung
Copy link
Copy Markdown
Contributor

💡 PR 제목

예: feat: [HYJ] role 수정


🔗 관련 이슈

진행 중이면 Refs #123, 완전 해결이면 Closes #123 (완전히 끝났을 때만)

  • Refs/Closes: #

📌 작업 내용 요약

  • 주요 변경 1
  • 주요 변경 2
  • 주요 변경 3

🧱 변경 범위 (Scope)

Backend

  • API 추가/수정
  • Validation/예외처리
  • 인증/인가
  • DB 스키마/쿼리
  • 기타:

Frontend

  • UI/라우팅
  • 상태관리/비동기 로직
  • 입력값/검증
  • 기타:

🧪 테스트 내역

Backend

  • 로컬에서 애플리케이션 실행 확인
  • 단위 테스트 통과
  • API 수동 테스트 (Postman / Swagger 등)

Frontend

  • npm run dev 로컬 실행 확인
  • 주요 화면/기능 수동 테스트

테스트 상세(필수)

테스트한 API/페이지/케이스를 간단히 적어주세요.

  • 예) 로그인 성공/실패, 회원가입, 목록 조회 등

🖼️ 화면 캡처 / 시연 영상 (Frontend 변경 시 권장)

  • before:
  • after:

⚠️ 영향도 / 리스크 / 롤백

리뷰어가 “머지해도 되는지” 판단하기 위한 섹션입니다.

  • 영향도: (예: 기존 API 응답 변경 없음 / 있음)
  • 리스크: (예: 권한 로직 수정, 쿼리 성능, 마이그레이션 필요 등)
  • 롤백 방법: (예: revert 커밋 / 기능 플래그 off / 마이그레이션 롤백 불가 등)

✅ 리뷰어 체크 포인트 (선택)

리뷰어가 집중해서 봐줬으면 하는 부분이 있으면 적어주세요.

  • 예) 트랜잭션 범위, 권한 체크, N+1, 상태관리 로직 등

Copy link
Copy Markdown
Contributor

@rlaalsdn0421 rlaalsdn0421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rlaalsdn0421 rlaalsdn0421 merged commit 663c3a2 into develop Apr 30, 2026
1 check passed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request primarily focuses on cleaning up source code by removing redundant comments and refining role-based access control logic within the payment and review services. Key changes include the removal of explanatory comments in several DTOs and the implementation of role string processing in ReviewService. Feedback indicates a security concern in createReview where the user's role should be re-validated against the database to comply with architectural principles. Furthermore, the manual removal of the 'ROLE_' prefix is identified as unnecessary and inconsistent with other service implementations, with suggestions provided to simplify the role verification logic.

Comment on lines +42 to 45
String cleanedRole = userRole.replace("ROLE_", "");
if (!"CUSTOMER".equals(cleanedRole)) {
throw new BusinessException(ErrorCode.ACCESS_DENIED);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

아키텍처 원칙(Security & Auth 1번)에 따라 토큰의 role과 실제 DB의 role을 매 요청마다 재검증해야 합니다. 현재 코드는 컨트롤러에서 전달받은 userRole(JWT 기반)만 확인하고 있어, DB에서 권한이 변경된 경우를 감지할 수 없습니다. PaymentService의 구현 방식과 동일하게 DB에서 조회한 user 객체의 권한을 직접 확인하도록 수정하십시오.

        if (!"CUSTOMER".equals(user.getUserRole().name())) {
            throw new BusinessException(ErrorCode.ACCESS_DENIED);
        }
References
  1. JWT: 토큰 내 role과 실제 DB role을 매 요청마다 재검증하는 로직 포함 (link)

Comment on lines +101 to 105
// ROLE_ 접두사 제거 후 비교
String cleanedRole = user.getUserRole().name().replace("ROLE_", "");
if (!"CUSTOMER".equals(cleanedRole)) {
throw new BusinessException(ErrorCode.ACCESS_DENIED);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

DB에서 조회한 Enum의 name()을 호출할 때 ROLE_ 접두사를 제거하는 로직은 불필요합니다. UserRole Enum 정의에 ROLE_ 접두사가 포함되어 있지 않다면(PaymentService의 구현을 참고할 때 포함되지 않은 것으로 보임), 단순 문자열 비교만으로 충분합니다. 불필요한 가공 로직을 제거하여 코드를 간결하게 유지하십시오.

        if (!"CUSTOMER".equals(user.getUserRole().name())) {
            throw new BusinessException(ErrorCode.ACCESS_DENIED);
        }

Comment on lines +139 to 143
// ROLE_ 접두사 제거 후 비교
String cleanedRole = user.getUserRole().name().replace("ROLE_", "");
if (!"CUSTOMER".equals(cleanedRole)) {
throw new BusinessException(ErrorCode.ACCESS_DENIED);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

위와 동일하게, 불필요한 문자열 치환 로직을 제거하고 DB의 권한 정보를 직접 비교하는 방식을 권장합니다.

        if (!"CUSTOMER".equals(user.getUserRole().name())) {
            throw new BusinessException(ErrorCode.ACCESS_DENIED);
        }

Comment on lines +174 to +175
// DB에서 가져온 역할을 "CUSTOMER", "OWNER" 등으로 통일
String dbRole = user.getUserRole().name().replace("ROLE_", "");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Enum의 name() 결과에서 ROLE_을 제거하는 처리는 중복되거나 불필요해 보입니다. PaymentService와의 일관성을 위해 불필요한 가공 로직을 제거하고 원본 Enum 이름을 사용하십시오.

Suggested change
// DB에서 가져온 역할을 "CUSTOMER", "OWNER" 등으로 통일
String dbRole = user.getUserRole().name().replace("ROLE_", "");
// DB에서 가져온 역할을 사용하여 권한 확인
String dbRole = user.getUserRole().name();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants