@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.formLogin().disable()
.httpBasic().disable()
.csrf().disable()
.headers().frameOptions().disable()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeHttpRequests()
.requestMatchers("/","/css/**","/images/**","/js/**","/favicon.ico","/h2-console/**").permitAll()
.requestMatchers("").permitAll()
.anyRequest().authenticated()
.and()
.oauth2Login()
.successHandler(oAuth2LoginSuccessHandler)
.failureHandler(oAuth2LoginFailureHandler);
http.addFilterBefore(jwtAuthenticationProcessingFilter(), LogoutFilter.class);
return http.build();
}
- FormLogin 사용 X
- httpBasic 사용 X
- csrf 보안 사용 X
- 세션 사용하지 않으므로 STATELESS로 설정
기본 페이지, css, image, js 하위 폴더에 있는 자료들은 모두 접근 가능, h2-console에 접근 가능하게 만들었고, 설정한 경로 외에는 인증된 사용자만 접근 가능.
jwtAuthenticationProcessingFilter()를 로그아웃전에 동작하게 만듦.