@豆子 public SecurityFilterChain filterChain(HttpSecurity http) 抛出异常 {
return http.csrf().disable()
.authorizeHttpRequests()
.requestMatchers("/home/normal")
.permitAll()
.and()
.authorizeHttpRequests().requestMatchers("/products/**")
.authenticated().and().formLogin().and().build();
}
如何编写 .csrf() 、.authorizeHttpRequests()、.formLogin() 因为它显示已弃用并标记为删除的错误。我正在使用 springboot 3.2 版本和 spring security 6.2
@Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.csrf(CsrfConfigurer::disable)
.authorizeHttpRequests()
.requestMatchers("/home/normal")
.permitAll()
.and()
.authorizeHttpRequests().requestMatchers("/products/**")
.authenticated().and().formLogin().and().build();
}