스프링 시큐리티 관련 질문
-
게시물 수정 , 삭제는 로그인 필요
다음과 같이 "/webjars/**", "/js/**", "/image/**", "/", "/auth/**" 이 경로들은 인증 없이 접근을 허용하도록 했는데 모든 화면이 403 forbidden이 출력됩니다. 이 문제를 해결하려면 어떻게 해야할지 궁금합니다.
--------------------------------------------------------------------------------------
package com.ssamz.jblog.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.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
@Configuration
@EnableWebSecurity
public class JBlogWebSecurityConfiguration {
@Bean
protected SecurityFilterChain webSecurityFilterChain(HttpSecurity http) throws Exception {
// 인증 없이 접근을 허용하는 경로
// "/webjars/**", "/js/**", "/image/**", "/", "/auth/**"
http
.cors(AbstractHttpConfigurer::disable)
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(auth -> auth.requestMatchers(new AntPathRequestMatcher("/webjars/**")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/js/**")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/image/**")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/auth/**")).permitAll()
.anyRequest().authenticated()
);
return http.build();
}
}
--------------------------------------------------------------------------------------
#스프링 시큐리티 #스프링 시큐리티 로그인 #스프링 시큐리티 jwt #스프링 시큐리티 로그인 페이지 없애기 #스프링 시큐리티 쓰는 이유 #스프링 시큐리티 jwt 로그인 #스프링 시큐리티 로그아웃 #스프링 시큐리티 oauth2 #스프링 시큐리티 인 액션 #스프링 시큐리티 필터