英文:
Spring security: save sessions status and get sessions after restart app
问题
我使用Spring Security,它会在用户经过授权时创建会话。如果我重新启动应用程序,我希望获取所有活动会话。这意味着如果用户已经经过授权并且我重新加载了应用程序,用户就不需要再次进行授权,他应该继续在自己的会话中工作。我该如何实现这一点?
英文:
I use spring security, that create sessions if user has authorized. I want to get all active sessions if I restart my app. This means that if the user is authorized and I reloaded my application, the user should not be authorized again, he should continue to work in his session. How can i did this?
答案1
得分: 1
将所有会话详细信息存储在数据库或缓存中。
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
</dependency>
或
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
请参阅以下文档:
缓存:https://spring.io/projects/spring-session-data-redis
数据库:https://spring.io/projects/spring-session-jdbc
会话属性:https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#security-properties
英文:
Store all the session details either in the database or Cache.
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
</dependency>
or
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
Refer to the below documentation,
Cache: https://spring.io/projects/spring-session-data-redis
Database: https://spring.io/projects/spring-session-jdbc
Session Properties: https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#security-properties
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论