Skip to content

Commit

Permalink
chore : cookie validation 제외할 uri 메서드 및 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sk000801 committed Aug 14, 2024
1 parent 5aaf698 commit a6601ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/oauth/config/FilterConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenValidationFilter> accessTokenValidationFilter(JwtService jwtService) {
FilterRegistrationBean<TokenValidationFilter> 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;
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/oauth/config/TokenValidationFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> excludeUrls = new ArrayList<>();

@Override
public void init(FilterConfig filterConfig) throws ServletException {
Expand Down Expand Up @@ -62,4 +65,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
public void destroy() {
// 필터 종료 작업이 필요하면 여기에 작성
}

public void setExcludeUrls(List<String> excludeUrls) {
this.excludeUrls = excludeUrls;
}
}

0 comments on commit a6601ee

Please sign in to comment.