기존 코드
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
public class SecurityConfig {
@Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/usr/register").permitAll() // 문제 발생
.requestMatchers("/usr/login").anonymous()
.anyRequest().authenticated())
...
.build();
}
...
}
수정한 코드1
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
public class SecurityConfig {
@Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.authorizeHttpRequests(auth -> auth
.requestMatchers(new AntPathRequestMatcher("/usr/register")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/usr/login")).anonymous()
.anyRequest().authenticated())
...
.build();
}
...
}
수정한 코드2
import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher;
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
public class SecurityConfig {
@Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.authorizeHttpRequests(auth -> auth
.requestMatchers(antMatcher("/usr/register")).permitAll()
.requestMatchers(antMatcher("/usr/login")).anonymous()
.anyRequest().authenticated())
...
.build();
}
...
}
참고 자료
https://spring.io/security/cve-2023-34035
https://marco.dev/spring-boot-h2-error
'공부 기록 > 오류 기록' 카테고리의 다른 글
윈도우 환경에서 H2 데이터베이스 연결 시 경로 not found 오류 해결 (0) | 2023.06.11 |
---|---|
git push 시 충돌로 인해 Rebase and Merge가 불가능한 오류 해결 (0) | 2023.06.08 |
Updates were rejected because the tip of your current branch is behind 오류 해결 (0) | 2023.04.30 |
Java file outside of source root 오류 해결 (0) | 2023.04.30 |