Spring security Spring oauth2/HttpSecurity http/ResourceServerConfigurer和WebSecurity配置器适配器

Spring security Spring oauth2/HttpSecurity http/ResourceServerConfigurer和WebSecurity配置器适配器,spring-security,spring-boot,spring-security-oauth2,Spring Security,Spring Boot,Spring Security Oauth2,我在oauth2中使用Spring安全性,但我有一个问题,我没有找到任何答案,在许多项目示例中,您已经配置了2次(HttpSecurity http) 例如在 而且 因此,我的问题是,为什么要在WebSecurityConfigureAdapter或ResourceServerConfigurerAdapter中配置http安全性?ResourceServerConfigurerAdapter是为不同于WebSecurityConfigureAdapter的端点配置的(请参见antMatche

我在oauth2中使用Spring安全性,但我有一个问题,我没有找到任何答案,在许多项目示例中,您已经配置了2次(HttpSecurity http)

例如在

而且


因此,我的问题是,为什么要在WebSecurityConfigureAdapter或ResourceServerConfigurerAdapter中配置http安全性?ResourceServerConfigurerAdapter是为不同于WebSecurityConfigureAdapter的端点配置的(请参见antMatchers)

这两个适配器之间的区别在于,ResourceServerConfigurerAdapter使用一个特殊的过滤器来检查请求中的承载令牌,以通过OAuth2对请求进行身份验证

WebSecurityConfigureAdapter用于通过会话(在给定示例中为表单登录)对用户进行身份验证