diff --git a/src/main/java/team/haedal/gifticionfunding/auth/config/JwtAuthorizationFilter.java b/src/main/java/team/haedal/gifticionfunding/auth/config/JwtAuthorizationFilter.java index 317d438..e5b8e38 100644 --- a/src/main/java/team/haedal/gifticionfunding/auth/config/JwtAuthorizationFilter.java +++ b/src/main/java/team/haedal/gifticionfunding/auth/config/JwtAuthorizationFilter.java @@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.Authentication; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -23,14 +24,18 @@ @Component @RequiredArgsConstructor +@Slf4j public class JwtAuthorizationFilter extends OncePerRequestFilter { private final JwtProvider jwtProvider; @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { + log.info("dofilterinternal 실행"); + + if (request.getRequestURI().startsWith("/oauth2") || request.getRequestURI().startsWith("/refresh") ||request.getRequestURI().startsWith("/swagger-ui")||request.getRequestURI().startsWith("/api-docs")||request.getRequestURI().startsWith("/v3")) { + log.info("다음필터 실행"); - if (request.getRequestURI().startsWith("/oauth2") | request.getRequestURI().startsWith("/refresh")) { filterChain.doFilter(request, response); return; } @@ -48,6 +53,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse throw new IllegalArgumentException("예상치 못한 토큰 오류"); } + log.info("다음필터 실행"); // 다음 Filter를 실행하기 위한 코드. 마지막 필터라면 필터 실행 후 리소스를 반환한다. filterChain.doFilter(request, response); } diff --git a/src/main/java/team/haedal/gifticionfunding/auth/config/SecurityConfig.java b/src/main/java/team/haedal/gifticionfunding/auth/config/SecurityConfig.java index f66668f..e1f8991 100644 --- a/src/main/java/team/haedal/gifticionfunding/auth/config/SecurityConfig.java +++ b/src/main/java/team/haedal/gifticionfunding/auth/config/SecurityConfig.java @@ -1,6 +1,7 @@ package team.haedal.gifticionfunding.auth.config; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; @@ -21,6 +22,7 @@ @Configuration @EnableWebSecurity @RequiredArgsConstructor +@Slf4j public class SecurityConfig { private final CustomAuthenticationEntryPoint customAuthenticationEntryPoint; private final CustomAccessDeniedHandler customAccessDeniedHandler; @@ -38,6 +40,7 @@ public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + log.info("필터체인 실행"); http .csrf(AbstractHttpConfigurer::disable) .cors(c -> c.configurationSource(corsConfigSource())) @@ -45,7 +48,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .authorizeHttpRequests(authReq -> authReq .requestMatchers(HttpMethod.OPTIONS).permitAll() - .requestMatchers("/", "/login", "/oauth2/**", "/refresh").permitAll() + .requestMatchers("/", "/login", "/oauth2/**", "/refresh","/swagger-ui/**","/api-docs","/v3/api-docs/**").permitAll() .anyRequest().authenticated()) .exceptionHandling(e -> e .authenticationEntryPoint(customAuthenticationEntryPoint)