【问题标题】:Spring oauth2 / HttpSecurity http / ResourceServerConfigurer and WebSecurityConfigurerAdapterSpring oauth2 / HttpSecurity http / ResourceServerConfigurer 和 WebSecurityConfigurerAdapter
【发布时间】:2016-09-14 07:07:34
【问题描述】:

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

例如https://github.com/spring-projects/spring-security-oauth/blob/master/samples/oauth2/sparklr/src/main/java/org/springframework/security/oauth/examples/sparklr/config/SecurityConfiguration.java

还有

https://github.com/spring-projects/spring-security-oauth/blob/master/samples/oauth2/sparklr/src/main/java/org/springframework/security/oauth/examples/sparklr/config/OAuth2ServerConfig.java

所以我的问题是为什么要配置以及何时在 WebSecurityConfigurerAdapter 或 ResourceServerConfigurerAdapter 中配置 http 安全性?

【问题讨论】:

    标签: spring-security spring-boot spring-security-oauth2


    【解决方案1】:

    ResourceServerConfigurerAdapter 配置用于与 WebSecurityConfigurerAdapter 不同的端点(请参阅 antMatchers)。

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

    WebSecurityConfigurerAdapter 用于通过会话对用户进行身份验证(在您给定的示例中,表单登录)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-31
      • 2018-11-04
      • 2016-03-14
      • 1970-01-01
      • 2023-01-17
      • 1970-01-01
      • 2019-05-28
      • 2020-03-04
      相关资源
      最近更新 更多