我刚开始使用Spring Session和Spring Security。希望能得到帮助。我想在REST API上使用Spring Session和Spring Security,并使用Redis来存储会话信息。我遵循了http://docs.spring.io/spring-session/docs/current/reference/html5/guides/rest.html中的示例,但我使用的是xml而不是Java,并且我使用的是Spring3.2.4。
使用curl的username:password没有问题,x-auth-token保存在Redis中,头部获取200ok。但是,当我在没有用户名和密码的情况下使用curl时,会遇到问题。获取401未授权,但header中返回了x-auth-token,也保存在Redis中
`< HTTP/1.1 401 Unauthorized * Server Apache-Coyote/1.1 is not blacklisted < Server: Apache-Coyote/1.1 < x-auth-token: 71554566-17d3-44ca-94b8-009d090c61a1 < Content-Type: text/html;charset=utf-8 < Content-Language: en < Content-Length: 1018 < Date: Mon, 21 Mar 2016 14:40:18 GMT`发布于 2016-03-23 23:37:36
我猜这是因为之前的请求正在被保存。您可以使用NullRequestCache修复此问题。在XML中,您可以利用。配置如下所示:
<http ...>
<request-cache ref="requestCache"/>
</http>
<b:bean id="requestCache" class="org.springframework.security.web.savedrequest.NullRequestCache"/>https://stackoverflow.com/questions/36134744
复制相似问题