Spring Security:保存会话状态,并在应用程序重新启动后获取会话。

huangapple go评论80阅读模式
英文:

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.

  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework.session&lt;/groupId&gt;
    &lt;artifactId&gt;spring-session-jdbc&lt;/artifactId&gt;
  &lt;/dependency&gt;

or

&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.session&lt;/groupId&gt;
    &lt;artifactId&gt;spring-session-data-redis&lt;/artifactId&gt;
&lt;/dependency&gt;

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

huangapple
  • 本文由 发表于 2020年7月24日 23:17:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63076524.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定