Skip to content

fix: 세션 소유자 검증 시 존재 여부와 권한을 분리하여 처리#59

Merged
Boyeon-Shin merged 1 commit intomainfrom
fix/sse-session-authorization
Apr 24, 2026
Merged

fix: 세션 소유자 검증 시 존재 여부와 권한을 분리하여 처리#59
Boyeon-Shin merged 1 commit intomainfrom
fix/sse-session-authorization

Conversation

@Boyeon-Shin
Copy link
Copy Markdown
Collaborator

📌 관련 이슈 (Related Issue)

📝 작업 내용 (Description)

세션 소유자 검증 시 존재 여부와 권한을 분리

🔄 변경 유형 (Type of Change)

  • ✨ 새로운 기능 (feat)
  • 🐛 버그 수정 (fix)
  • 📝 문서 수정 (docs)
  • 💄 스타일 (style)
  • ♻️ 리팩토링 (refactor)
  • ✅ 테스트 (test)
  • 🔧 기타 (chore)

✅ 체크리스트 (Checklist)

  • 코드가 정상적으로 동작하는지 확인했습니다
  • 기존 테스트가 통과합니다
  • 필요한 경우 새로운 테스트를 추가했습니다

@Boyeon-Shin Boyeon-Shin self-assigned this Apr 24, 2026
Copy link
Copy Markdown

@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 refactors the session ownership validation logic by introducing a specific SESSION_NOT_FOUND error code and updating QuestionService to fetch the session entity directly. The reviewer suggested improving the validateSessionOwner method by adding @transactional(readOnly = true) for consistency and returning the InterviewSession object to allow callers to reuse the fetched data and avoid redundant database lookups.

Comment on lines 82 to 87
public void validateSessionOwner(UUID sessionId, UUID memberId) {
if(!sessionRepository.existsByIdAndMemberId(sessionId, memberId)) {
InterviewSession session = sessionRepository.findById(sessionId)
.orElseThrow(() -> new BusinessException(ErrorCode.SESSION_NOT_FOUND));
if (!session.getMemberId().equals(memberId)) {
throw new BusinessException(ErrorCode.FORBIDDEN);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

해당 메서드는 데이터베이스 조회 작업을 수행하므로, 다른 조회 메서드들과의 일관성을 위해 @Transactional(readOnly = true) 어노테이션을 추가하는 것이 좋습니다. 또한, 검증된 세션 객체를 호출부에서 다시 사용할 가능성이 높으므로, void 대신 InterviewSession을 반환하도록 개선하면 중복 조회를 방지할 수 있습니다.

    @Transactional(readOnly = true)
    public InterviewSession validateSessionOwner(UUID sessionId, UUID memberId) {
        InterviewSession session = sessionRepository.findById(sessionId)
                .orElseThrow(() -> new BusinessException(ErrorCode.SESSION_NOT_FOUND));
        if (!session.getMemberId().equals(memberId)) {
            throw new BusinessException(ErrorCode.FORBIDDEN);
        }
        return session;

@Boyeon-Shin Boyeon-Shin merged commit 0d9059a into main Apr 24, 2026
4 checks passed
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.

fix: SSE 구독 엔드포인트 권한 확인 누락

1 participant