Skip to content

[FEAT/#112] 토큰 인증 실패 시 응답 상태 코드 오류 수정 및 인증 필터·화이트리스트 정비#113

Merged
ckkim817 merged 4 commits intodevelopfrom
feat/#112
Aug 6, 2025
Merged

[FEAT/#112] 토큰 인증 실패 시 응답 상태 코드 오류 수정 및 인증 필터·화이트리스트 정비#113
ckkim817 merged 4 commits intodevelopfrom
feat/#112

Conversation

@ckkim817
Copy link
Member

@ckkim817 ckkim817 commented Aug 6, 2025

💡 Issue

📄 Description

  • 액세스 토큰 만료 등으로 인한 토큰 인증 실패 시 401이 아닌 403 에러를 반환하던 오류를 수정했습니다.
  • 인증 필터의 Bearer 파싱을 보강하고, 토큰 검증 및 예외 처리 로직을 401 에러 응답으로 통일했습니다.
  • v2 버저닝 추가에 따라 SecurityConfig의 화이트리스트를 정비했습니다.

@ckkim817 ckkim817 requested a review from Copilot August 6, 2025 17:56
@ckkim817 ckkim817 self-assigned this Aug 6, 2025
@ckkim817 ckkim817 added 🛠️ FIX 버그, 오류 등을 수정 ♻️ REFACTOR 코드 리팩토링 🐈‍⬛ 창균 size/M labels Aug 6, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses token authentication failures by fixing status code errors and refactoring authentication filters. The primary issue was returning 403 (Forbidden) instead of 401 (Unauthorized) for expired or invalid tokens.

  • Fixed HTTP status code from 403 to 401 for JWT authentication failures
  • Enhanced Bearer token parsing and validation in authentication filter
  • Updated whitelist configuration for v2 API versioning

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
SecurityConfig.java Updated whitelist to include v2 auth endpoints and cleaned up configuration formatting
JwtAuthenticationException.java Added new custom exception class for JWT authentication errors
JwtAuthenticationFilter.java Refactored token validation logic with proper exception handling and Bearer token parsing
CustomJwtAuthenticationEntryPoint.java Fixed status code from 403 to 401 for authentication failures

case EXPIRED_JWT_TOKEN -> new JwtAuthenticationException(ErrorType.EXPIRED_ACCESS_TOKEN_ERROR);
case INVALID_JWT_SIGNATURE, INVALID_JWT_TOKEN, UNSUPPORTED_JWT_TOKEN, EMPTY_JWT ->
new JwtAuthenticationException(ErrorType.INVALID_ACCESS_TOKEN_ERROR);
case VALID_JWT -> throw new IllegalStateException("VALID_JWT should not reach mapToAuthException");
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The error message should be more descriptive. Consider adding context about the internal error: "Internal error: VALID_JWT token should not be mapped to an authentication exception"

Suggested change
case VALID_JWT -> throw new IllegalStateException("VALID_JWT should not reach mapToAuthException");
case VALID_JWT -> throw new IllegalStateException("Internal error: VALID_JWT token should not be mapped to an authentication exception. This indicates a logic error in the authentication flow. Please check the JWT validation and filter logic.");

Copilot uses AI. Check for mistakes.
@ckkim817 ckkim817 merged commit 36c2901 into develop Aug 6, 2025
1 check passed
@ckkim817 ckkim817 deleted the feat/#112 branch August 6, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ FIX 버그, 오류 등을 수정 ♻️ REFACTOR 코드 리팩토링 size/M 🐈‍⬛ 창균

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] 토큰 인증 실패 시 응답 상태 코드 오류 수정 및 인증 필터·화이트리스트 정비

2 participants