使用Waffle的Spring Security返回匿名用户

时间:2018-06-22 19:20:32

标签: spring spring-security

我有一个问题,其中getPrincipal()返回匿名用户。但是,这并非对我网站的所有实例都发生,仅在Chrome上发生。实际上,我似乎是唯一遇到此问题的用户。

在日志中,getPrincipal()返回anonymousUser,然后下一条日志消息显示我已经成功登录。

这可能是Chrome的问题吗?

配置

<security:http entry-point-ref="negotiateSecurityFilterEntryPoint">
    <security:csrf disabled="true"/>
    <security:intercept-url pattern="/**/MySiteURL" access="isFullyAuthenticated()" />
    <security:custom-filter ref="waffleNegotiateSecurityFilter" position="BASIC_AUTH_FILTER" />
</security:http>

代码

String user = SecurityContextHolder.getContext().getAuthentication()
                .getPrincipal().toString();

日志消息

2018-06-21 08:16:33.016 20732798 [http-nio-161.179.78.42-80-exec-4] INFO  c.t.a.b.f.UIImpl - getUserRole() User: anonymousUser 
2018-06-21 08:16:33.125 20732907 [http-nio-161.179.78.42-80-exec-5] INFO  w.spring.NegotiateSecurityFilter - successfully logged in user: TEST\TestUser

0 个答案:

没有答案