简体   繁体   English

春季安全记得我认证

[英]spring security remember me authentication

I have the mechanism to save cookies at the client-side. 我有在客户端保存cookie的机制。 But when I was trying to implement remember-me using spring security I came upon this tutorial : 但是,当我尝试使用Spring Security实现“记住我”功能时,我遇到了本教程:

http://static.springsource.org/spring-security/site/docs/3.0.x/reference/remember-me.html#remember-me-persistent-token http://static.springsource.org/spring-security/site/docs/3.0.x/reference/remember-me.html#remember-me-persistent-token

but here everything is abstract and no examples are given.. Can someone tell me how can I use the interfaces mentioned in this tutorial in my application where I need to implement persistent cookies... And kindly tell me what do I need to define in my security.xml file? 但是这里的所有内容都是抽象的,没有给出任何示例。.有人可以告诉我如何在需要实现持久性cookie的应用程序中使用本教程中提到的接口吗?请告诉我我需要在其中定义什么我的security.xml文件?

I am authenticating my user against RESTful services.. 我正在根据RESTful服务对用户进行身份验证。

The official documentation is not abstract. 官方文档不是摘要。 Turning on remember-me with Spring Security is very simple (I suppose that Spring Security already configured and users are stored in DB): 使用Spring Security打开“记住我”非常简单(我想已经配置了Spring Security,并且用户存储在DB中):

1 Turn on remeber-me in the conf : 1在conf中启用remeber-me:

<http>
    ...
    <remember-me data-source-ref="yourDataSource"/>
</http>

2 Create corresponding table in the database: 2在数据库中创建相应的表:

create table persistent_logins (username varchar(64) not null, series varchar(64) primary key, token varchar(64) not null, last_used timestamp not null)

3 Add corresponding checkbox to your login form: 3在您的登录表单中添加相应的复选框:

<input id="rememeberMe" type="checkbox" name="_spring_security_remember_me">

In a case of REST you need to adjust third step according to your authentication scenrio. 对于REST,您需要根据身份验证场景调整第三步。

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

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