【发布时间】:2017-02-11 23:12:27
【问题描述】:
我想创建一个 RESTful API,我需要它是无状态的,因为我可能会启动 N 次应用程序。
我还添加了带有 jdbc 实现的 OAuth2,用户应该登录一次,所有查询都应该是无状态的。
在我的 Spring Boot 应用程序中添加以下内容会导致它现在尝试进行两次身份验证的登录崩溃。
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
在服务器端我有这些日志:
AuditEvent [timestamp=Tue Oct 04 05:04:52 ICT 2016, principal=dka, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null}]
AuditEvent [timestamp=Tue Oct 04 05:04:52 ICT 2016, principal=anonymousUser, type=AUTHORIZATION_FAILURE, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null, type=org.springframework.security.access.AccessDeniedException, message=Access is denied}]
- 这是否也涉及我的 OAuth 身份验证或仅涉及 WebSecurity 部分?
- 有没有一种好的方法来配置我的会话以扩展它并保持服务无状态?
【问题讨论】:
标签: spring rest spring-security spring-boot stateless