Skip to content

Commit

Permalink
[REFACTOR] 인증 제외 대상 URI 리스트 상수화
Browse files Browse the repository at this point in the history
- [참고리뷰](#27 (comment))
  • Loading branch information
yummygyudon committed Dec 13, 2024
1 parent f7b4b4a commit 1e73869
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package sopt.makers.authentication.support.constant;

import java.util.List;

public final class SystemConstant {
private SystemConstant() {}

Expand All @@ -9,12 +11,15 @@ private SystemConstant() {}

public static final String API_DEFAULT_PREFIX = API_PATH_PREFIX + API_VERSION;

public static final String PATH_ACTUATOR = "/actuator";
public static final String PATH_AUTH = "/auth";
public static final String PATH_ERROR = "/error";
public static final String PATH_TEST = "/test";
private static final String PATH_ACTUATOR = "/actuator";
private static final String PATH_AUTH = API_DEFAULT_PREFIX + "/auth";
private static final String PATH_ERROR = "/error";
private static final String PATH_TEST = "/test";
private static final String PATH_GET_REGISTER_SOCIAL_PLATFORM =
API_PATH_PREFIX + "/social/accounts/social";

public static final String PATH_USER = API_DEFAULT_PREFIX + "/user";
public static List<String> WHITE_PATHS =
List.of(PATH_ACTUATOR, PATH_AUTH, PATH_GET_REGISTER_SOCIAL_PLATFORM, PATH_ERROR, PATH_TEST);

public static final String PATTERN_ALL = "/**";
public static final String PATTERN_ERROR_PATH = PATH_ERROR + PATTERN_ALL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package sopt.makers.authentication.support.security.filter;

import static sopt.makers.authentication.support.constant.SystemConstant.PATH_ACTUATOR;
import static sopt.makers.authentication.support.constant.SystemConstant.PATH_AUTH;
import static sopt.makers.authentication.support.constant.SystemConstant.PATH_ERROR;
import static sopt.makers.authentication.support.constant.SystemConstant.PATH_TEST;
import static sopt.makers.authentication.support.constant.SystemConstant.PATH_USER;
import static sopt.makers.authentication.support.constant.SystemConstant.WHITE_PATHS;

import sopt.makers.authentication.support.constant.JwtConstant;
import sopt.makers.authentication.support.jwt.provider.JwtAuthAccessTokenProvider;
Expand All @@ -29,7 +25,6 @@
@Component
@RequiredArgsConstructor
public class JwtAuthenticationFilter extends OncePerRequestFilter {
private static final String PATH_GET_REGISTER_SOCIAL_PLATFORM = PATH_USER + "/social";

private final JwtAuthAccessTokenProvider authTokenProvider;

Expand All @@ -54,11 +49,7 @@ public boolean shouldNotFilter(HttpServletRequest request) {

private boolean isWhiteRequest(final HttpServletRequest request) {
String url = request.getRequestURL().toString();
return url.contains(PATH_ACTUATOR)
|| url.contains(PATH_AUTH)
|| url.contains(PATH_ERROR)
|| url.contains(PATH_TEST)
|| url.contains(PATH_GET_REGISTER_SOCIAL_PLATFORM);
return WHITE_PATHS.stream().anyMatch(url::contains);
}

/**
Expand Down

0 comments on commit 1e73869

Please sign in to comment.