【问题标题】:An Authentication object was not found in the SecurityContext issue in Spring boot 1.5.9 and OAuth2在 Spring boot 1.5.9 和 OAuth2 的 SecurityContext 问题中找不到 Authentication 对象
【发布时间】:2017-12-02 01:49:46
【问题描述】:

我正在尝试使用示例应用程序 Spring Boot REST API Security with OAuth2 from https://gigsterous.github.io/engineering/2017/03/01/spring-boot-4.html 工作正常,示例使用 spring boot 1.4.0.RELEASE,但是当我切换到 1.5.9.RELEASE 时,我得到这个 Authentication object not found 问题。我在网上搜索了答案,但找不到任何解决问题的方法。有人说过滤器链的顺序是原因。但似乎没有人能够提出解决方案。

感谢任何帮助。

【问题讨论】:

    标签: spring-boot spring-security-oauth2


    【解决方案1】:

    我找到了解决方案:

    @Configuration
    @EnableWebSecurity
    @EnableGlobalMethodSecurity(prePostEnabled = true)
    @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
    public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    

    添加@Order 注释解决了这个问题。现在我可以使用 1.5.9.RELEASE。我是从https://github.com/spring-guides/tut-spring-boot-oauth2/tree/master/auth-server 找到的

    【讨论】:

      猜你喜欢
      • 2016-11-12
      • 2019-10-28
      • 2022-01-22
      • 2013-03-08
      • 2014-04-04
      • 2013-05-09
      • 2013-05-18
      • 2016-03-11
      • 1970-01-01
      相关资源
      最近更新 更多