fix: SSE 세션 구독 엔드포인트에 소유자 인가 검증 추가(#51)#58
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements ownership validation for interview session subscriptions by adding a check to ensure the requesting user owns the session. Changes include a new repository method for existence checks and a validation method in the QuestionService. Review feedback suggests optimizing the validation logic with @transactional(readOnly = true), improving code formatting for the if statement, and using RESOURCE_NOT_FOUND instead of FORBIDDEN to enhance security and maintain consistency with other service methods.
| public void validateSessionOwner(UUID sessionId, UUID memberId) { | ||
| if(!sessionRepository.existsByIdAndMemberId(sessionId, memberId)) { | ||
| throw new BusinessException(ErrorCode.FORBIDDEN); |
There was a problem hiding this comment.
데이터베이스 조회 작업의 일관성과 성능 최적화를 위해 @Transactional(readOnly = true) 어노테이션을 추가하고, 자바 코딩 컨벤션에 맞춰 if 문 뒤에 공백을 추가하는 것이 좋습니다. 또한, 동일 클래스의 getQuestion 메서드(45-48라인)와 일관성을 유지하기 위해 권한이 없거나 리소스가 없는 경우 FORBIDDEN 대신 RESOURCE_NOT_FOUND를 사용하는 것을 고려해 보세요. 이는 리소스의 존재 여부를 불필요하게 노출하지 않는 보안 관행과도 부합합니다.
@Transactional(readOnly = true)
public void validateSessionOwner(UUID sessionId, UUID memberId) {
if (!sessionRepository.existsByIdAndMemberId(sessionId, memberId)) {
throw new BusinessException(ErrorCode.RESOURCE_NOT_FOUND);
📌 관련 이슈 (Related Issue)
📝 작업 내용 (Description)
SSE 세션 구독 엔드포인트에 소유자 인가 검증 추가
🔄 변경 유형 (Type of Change)
✅ 체크리스트 (Checklist)