Spring boot Security Filter에 예외 URL 적용
2024. 9. 8. 23:20ㆍJava/Spring Boot Security
String[] exceptUrl = {
"/",
"/error",
};
OrRequestMatcher orRequestMathcers = new OrRequestMatcher(Util.getRequestMatcher(exceptUrl));
NegatedRequestMatcher negatedRequestMatcher = new NegatedRequestMatcher(orRequestMathcers);
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests((requests) -> requests
.requestMatchers(exceptUrl).permitAll()
.anyRequest().authenticated())
.addFilterBefore(new SecurityFilter(negatedRequestMatcher), UsernamePasswordAuthenticationFilter.class)
.formLogin((form) -> form
.loginPage("/login")
.permitAll())
.logout((logout) -> logout.permitAll());
return http.build();
}
'Java > Spring Boot Security' 카테고리의 다른 글
Spring Boot Security 2Factor 인증 로직 (1) | 2024.09.29 |
---|---|
Spring boot Security login이외의 페이지에 exception 내용을 사용자에게 피드백 하기 (0) | 2024.09.14 |
Spring boot Security 결과값 초기화 방법 (1) | 2024.09.08 |
Spring boot Security 각 Class 역할 (0) | 2024.09.08 |
Spring boot Security /logout 실행시, blocked:mixed-content 에러 (0) | 2024.09.03 |