简体   繁体   English

春季:保存已登录的用户会话

[英]Spring: Save Logged In User Session

I don't understand where the current logged in user is saved in the application. 我不知道当前登录用户在应用程序中的保存位置。 I want to save the user (after his login) in my spring application. 我想将用户(在他登录后)保存在我的spring应用程序中。 I use Spring Security and already read about the SecurityContextHolder but the problem is I have a custom user class, which is saved in a mongodb. 我使用Spring Security,并且已经阅读了SecurityContextHolder但是问题是我有一个自定义用户类,该类保存在mongodb中。 I could query the user from the database after login (check the password and so on), but what are the next steps? 登录后我可以从数据库中查询用户(检查密码等),但是下一步是什么?

Greetings Chryb 问候Chryb

EDIT: 编辑:

My bigger question is how I should combine my user repository with my login? 我更大的问题是如何将用户存储库和登录信息结合起来?

EDIT: 编辑:

Look at my other question for more details here 这里查看我的其他问题以获取更多详细信息

Finally I have it! 终于我拥有了! This guide was a good help. 指南是一个很好的帮助。 The extra point is to write 额外的一点是写

@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(mongoSecurityService);
}

if you don't use .xml configuration. 如果您不使用.xml配置。 I have special thanks to guys who don't help answer the question and only flame the post like RC. 我要特别感谢那些不肯回答问题并且只会像RC那样发帖的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM