Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a 401 infinite loop error for APIs where access tokens are optional by reducing the whitelist and explicitly defining public endpoints. The changes replace a generic NO_PRINCIPAL_ERROR with a more specific UN_LOGIN_ERROR and implement precise endpoint security configuration using MvcRequestMatcher.Builder for path variable matching.
- Replaced generic authentication error with specific login error
- Reduced authentication whitelist from wildcard patterns to specific endpoints
- Added explicit public endpoint definitions with path variable constraints
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| SpotService.java | Changed error type from NO_PRINCIPAL_ERROR to UN_LOGIN_ERROR for guest users |
| SecurityConfig.java | Refactored security configuration to use specific endpoints instead of wildcards and added MvcRequestMatcher for precise path matching |
| .authorizeHttpRequests(auth -> auth | ||
| .requestMatchers(AUTH_WHITE_LIST).permitAll() | ||
| .requestMatchers(HttpMethod.GET, "/api/v1/app-updates").permitAll() | ||
| .requestMatchers(HttpMethod.POST, "/api/v1/spots").permitAll() |
There was a problem hiding this comment.
Allowing unrestricted POST access to create spots could be a security risk. Consider if anonymous users should be able to create spots without authentication.
Suggested change
| .requestMatchers(HttpMethod.POST, "/api/v1/spots").permitAll() |
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
@RequestMapping)으로 경로를 매칭하게 해 주는 도구인MvcRequestMatcher.Builder를 활용해 경로변수와 정규식 제약을 세밀하게 설정했습니다.