Conversation
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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."); |
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.
💡 Issue
📄 Description
SecurityConfig의 화이트리스트를 정비했습니다.