【发布时间】:2022-12-05 20:10:58
【问题描述】:
我正在学习有关 Spring Security 的课程,并且我试图让它在最新的 Spring Security 6 上工作。我正在尝试使用基本身份验证将 localhost:8080/ 从身份验证中列入白名单。但是当我访问 url 时,它仍然要求我提供凭据。
目前我有这个豆:
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.authorizeHttpRequests(auth -> {
auth.requestMatchers("/").permitAll();
auth.requestMatchers("index").permitAll();
auth.requestMatchers("/css/*").permitAll();
auth.requestMatchers("js/*").permitAll();
auth.anyRequest().authenticated();
}
)
.httpBasic(withDefaults()).build();
}
但是默认的“/”端点仍然没有列入白名单。
【问题讨论】:
标签: authentication spring-security spring-boot-3