fix: 인증 실패 시 401 상태 코드 반환 로직 추가#5
Merged
GoGradually merged 1 commit intomasterfrom Dec 31, 2025
Hidden character warning
The head ref may contain hidden characters: "fix/\uc778\uc99d-\uc2e4\ud328\uc2dc-\ub85c\uc9c1-\ubcc0\uacbd"
Merged
Conversation
Comment on lines
+99
to
+100
| .exceptionHandling(spec -> spec | ||
| .authenticationEntryPoint(new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED))) |
There was a problem hiding this comment.
인증 실패 처리 로직이 중복되어 있습니다.
(1) 문제점:
- JwtAuthenticationFilter의 handleAuthenticationError 메서드(36-39줄)에서 이미 401 상태 코드를 반환하고 있습니다.
- SecurityConfig의 authenticationEntryPoint도 동일하게 401을 반환하도록 설정되어 중복된 처리가 존재합니다.
(2) 영향:
- 코드 유지보수 시 두 곳을 모두 확인하고 수정해야 하는 부담이 있습니다.
- 두 핸들러가 다른 응답 형식을 반환할 경우 일관성 문제가 발생할 수 있습니다.
(3) 수정 제안:
인증 실패 처리 로직을 한 곳으로 통일하는 것을 권장합니다. authenticationEntryPoint는 인증되지 않은 요청에 대한 진입점 처리를 담당하고, JwtAuthenticationFilter의 에러 핸들러는 JWT 검증 실패 시의 처리를 담당하도록 역할을 명확히 분리하거나, 공통 에러 핸들러를 만들어 재사용하는 것이 좋습니다.
Comment on lines
+99
to
+100
| .exceptionHandling(spec -> spec | ||
| .authenticationEntryPoint(new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED))) |
There was a problem hiding this comment.
인증 실패 시나리오에 대한 테스트 커버리지가 부족합니다.
(1) 문제점:
- authenticationEntryPoint 설정이 추가되었지만, 이를 검증하는 테스트가 없습니다.
- 인증 실패 시 401 상태 코드가 제대로 반환되는지 확인하는 통합 테스트가 필요합니다.
(2) 영향:
- 향후 리팩토링이나 설정 변경 시 인증 실패 처리가 의도대로 동작하는지 검증할 수 없습니다.
- 회귀 버그 발생 위험이 높아집니다.
(3) 수정 제안:
다음 시나리오를 포함하는 테스트를 추가하시기 바랍니다:
- JWT 토큰 없이 인증이 필요한 엔드포인트에 접근 시 401 반환 확인
- 유효하지 않은 JWT 토큰으로 접근 시 401 반환 확인
- 만료된 JWT 토큰으로 접근 시 401 반환 확인
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.
hot fix