gpt4 book ai didi

spring-security - 在spring security中使用没有动词的requestMatchers().antMatchers()的原因是什么?

转载 作者:行者123 更新时间:2023-12-04 04:07:10 24 4
gpt4 key购买 nike

Spring security oauth 实现中有一个常见的做法是使用以下行来保护 oauth 端点:
.requestMatchers().antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access")
整个设置如下所示:

http
.formLogin().loginPage("/login").permitAll()
.and()
.requestMatchers().antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access")
.and()
.authorizeRequests().anyRequest().authenticated();

有人可以解释一下为什么需要该特定行,因为下一行明确表示所有请求都必须经过身份验证?

最佳答案

requestMatchers行指定安全检查适用于哪些请求。 authorizeRequests线进行实际的安全检查。

如果您忽略 requestMatchers行,所有请求都将被检查 authorizeRequests指定。如果没有对某些请求进行检查,则默认情况下检查会成功。

requestMatchers行,不匹配的请求将被其他剩余链检查。

关于spring-security - 在spring security中使用没有动词的requestMatchers().antMatchers()的原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38527723/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com