在Spring boot 1.5.9和OAuth2中的SecurityContext问题中找不到Authentication对象

时间:2017-12-01 17:30:03

标签: spring-boot spring-security-oauth2

我正在试用样本应用程序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对象未找到问题。我在网上搜索了一个答案,无法提出任何接近解决问题的方法。有人说过滤链的顺序是原因。但似乎没有人能够提出解决方案。

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:

@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

找到的
相关问题