java - 使用 Spring Boot 进行 session 管理?

标签 java spring spring-mvc authentication

我想使用 Spring Boot 设置 session 管理和身份验证。具体来说,当用户登录我的 Web 应用程序时,他们应该能够调用我的 REST API 来获取数据。此外,在一段时间后,它们应该会自动从系统中注销,此时任何 REST 调用也应该失败。如何使用 Spring Boot 完成此任务?

最佳答案

Spring Session 负责分布式 session 管理。

Spring Session provides an API and implementations for managing a user’s session information. It also provides transparent integration with:

HttpSession - allows replacing the HttpSession in an application container (i.e. Tomcat) neutral way. Additional features include:

Clustered Sessions - Spring Session makes it trivial to support clustered sessions without being tied to an application container specific solution.

Multiple Browser Sessions - Spring Session supports managing multiple users' sessions in a single browser instance (i.e. multiple authenticated accounts similar to Google).

RESTful APIs - Spring Session allows providing session ids in headers to work with RESTful APIs

关于java - 使用 Spring Boot 进行 session 管理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42043656/

相关文章:

java - Morphia for Mongo DB 和低性能代码

java - Spring Security 登录总是登陆一个没有消息的错误页面

java - Hibernate 5 和 Spring 4 MVC 中的 SessionFactory NoClassDefFoundError

spring-mvc - 是否可以使用 Spring MVC + PrimeFaces?

java - 编译代码时出现错误的操作数错误

java - 更好地设计跨方法的常见错误处理

java - libgdx - Actor 输入事件未触发

java - 如何将手动 SQL 行映射与 CrudRepository (Spring Data) 混合

spring - 使用保管库保护 Spring Cloud 配置凭据

java - 在 JSP 中编写 Hibernate 查询会给出 java.lang.NullPointerException