질문&답변
이렇게 한번 해보세요. package me.silvernine.jwttutorial.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; //@EnableWebSecurity @Configuration // 어노테이션 없으면 작동하지 않음 public class SecurityConfig { @Bean public WebSecurityCustomizer webSecurityCustomizer() { return (web) -> web.ignoring() .requestMatchers("/h2-console/**", "/favicon.ico"); } @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .authorizeRequests() .requestMatchers("/api/hello").permitAll() .and() .csrf().ignoringRequestMatchers(new AntPathRequestMatcher("/h2-console/**")) .and() .headers().frameOptions().disable() ; return http.build(); } }
2023-05-05T10:49:53.117Z
좋아요수
0
댓글수
3
조회수
2391