From a6601ee171fd235cdaf9dc79a527922b3ea8844e Mon Sep 17 00:00:00 2001 From: seokyung Date: Wed, 14 Aug 2024 16:04:16 +0900 Subject: [PATCH] =?UTF-8?q?chore=20:=20cookie=20validation=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8=ED=95=A0=20uri=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/oauth/config/FilterConfig.java | 9 +++++++-- src/main/java/oauth/config/TokenValidationFilter.java | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/oauth/config/FilterConfig.java b/src/main/java/oauth/config/FilterConfig.java index 627c81d..d61c84e 100644 --- a/src/main/java/oauth/config/FilterConfig.java +++ b/src/main/java/oauth/config/FilterConfig.java @@ -5,14 +5,19 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.util.Arrays; + @Configuration public class FilterConfig { @Bean public FilterRegistrationBean accessTokenValidationFilter(JwtService jwtService) { FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - registrationBean.setFilter(new TokenValidationFilter(jwtService)); - registrationBean.addUrlPatterns("/users/*"); // 필터를 적용할 URL 패턴 설정 + TokenValidationFilter filter = new TokenValidationFilter(jwtService); + + registrationBean.setFilter(filter); + filter.setExcludeUrls(Arrays.asList("/auth/*")); + return registrationBean; } } diff --git a/src/main/java/oauth/config/TokenValidationFilter.java b/src/main/java/oauth/config/TokenValidationFilter.java index 5c04c2d..c6253b3 100644 --- a/src/main/java/oauth/config/TokenValidationFilter.java +++ b/src/main/java/oauth/config/TokenValidationFilter.java @@ -13,12 +13,15 @@ import oauth.auth.JwtService; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; @RequiredArgsConstructor public class TokenValidationFilter implements Filter { private final JwtService jwtService; + private List excludeUrls = new ArrayList<>(); @Override public void init(FilterConfig filterConfig) throws ServletException { @@ -62,4 +65,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha public void destroy() { // 필터 종료 작업이 필요하면 여기에 작성 } + + public void setExcludeUrls(List excludeUrls) { + this.excludeUrls = excludeUrls; + } }