**已关闭。**此问题需要debugging details。它目前不接受回答。
编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答这个问题。
昨天关门了。
Improve this question
我想将此代码迁移到Spring Security 6.1.x
@Configuration
@EnableWebSecurity
public class SecurityConfiguration {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeRequests().requestMatchers("/").permitAll();
http.cors().and().csrf().disable();
return http.build();
}
}
我尝试使用authorizeHttpRequests,但它给了我403错误
2条答案
按热度按时间wtzytmuj1#
在stackoverflow上有很多关于如何迁移的帖子,但你也应该阅读下一个参考:
另外,您提供的
filterChain
将具有下一个主体:3xiyfsfu2#
欢迎来到Stack Overflow!
在第一个问题中,问题在于requestMatcher模式。您应该将其更改为
"/**"
,因为Spring MVC的模式匹配是相对于servlet路径的。这意味着,如果您将任何servletMap到以“/”开头且大于1的路径,则应使用此模式。正如this answer正确建议的那样,您可以将
authorizeHttpRequests
与lambda函数一起使用。