Spring Session Rest和AuthenticationManager

时间:2016-06-12 15:08:17

标签: spring-security spring-session

来自Spring Session Rest示例:http://docs.spring.io/spring-session/docs/current/reference/html5/guides/rest.html

我已在Cloud Foundry上部署了该示例,但它确实有效。 我想知道会话是如何使用Spring Security AuthenticationManager来验证第二个请求中的x-auth-token。 我检查了Spring Session中的代码,但没有找到任何细节。

据我了解,身份验证管理器将通过x-auth-token在SessionRepository中查找会话。

有人能告诉我Spring Session Rest中的身份验证是如何工作的吗?

1 个答案:

答案 0 :(得分:0)

实际上就Spring Security而言,与不使用Spring Session的应用程序(即使用Servlet容器的内部会话存储和JSESSIONID cookie)相比,此示例中没有任何不同。

Spring Session使用org.springframework.session.web.http.SessionRepositoryFilter将Servlet容器的HttpSession实现替换为Spring Session支持的自定义实现。此过滤器还提供HttpSessionStrategy(基于cookie或类似于您的示例中的HTTP请求标头),以将您提供的信息(再次通过cookie或标头)与存储在SessionRepository中的会话相关联实施您的选择。之后,完全取决于您的应用程序如何使用会话。

请注意,Spring Security的AuthenticationManager只处理提供的Authentication令牌的身份验证请求。它没有任何会话知识,也没有任何与web / Servlet API相关的知识。

相关问题