[英]How to correctly configure the remember me option of Spring Security in a project that use LDAP for authentication?
[英]How do I use “Remember Me” authentication with Spring Security and LDAP?
您实际上只需要为“记住我”属性提供一个数据源引用或一个令牌库引用以及一个用户服务引用。 我还看到了一些其他示例,这些示例在http元素中使用了基于投票者的access-decision-manager-ref,但是似乎使use-expressions =“ true”无效。 我对此不满意的唯一事情是必须两次指定ldap属性。
<beans:import resource="datasource-context.xml"/>
<http use-expressions="true" >
<intercept-url pattern="/auth/**" access="permitAll" />
<intercept-url pattern="/admin/**" access="hasRole('MY_ROLE_ADMIN')" />
<intercept-url pattern="/**" access="isAuthenticated()" />
<form-login />
<logout />
<remember-me key="_my_remember_me_key"
token-validity-seconds="864000"
data-source-ref="dataSource"
user-service-ref="ldapUserService" />
</http>
<ldap-server id="ldapServerContext" ldif="classpath:users.ldif" root="dc=springframework,dc=org" port="33389" />
<ldap-user-service
id="ldapUserService"
server-ref="ldapServerContext"
user-search-base="ou=people"
user-search-filter="(uid={0})"
group-search-base="ou=groups"
group-role-attribute="cn"
group-search-filter="(member={0})"
role-prefix="MY_ROLE_" />
<authentication-manager>
<ldap-authentication-provider
server-ref="ldapServerContext"
user-search-base="ou=people"
user-search-filter="(uid={0})"
group-search-base="ou=groups"
group-role-attribute="cn"
group-search-filter="(member={0})"
role-prefix="MY_ROLE_" />
</authentication-manager>
该链接应有助于:
http://static.springsource.org/spring-security/site/docs/3.0.x/reference/remember-me.html
重要的提示:
如果您正在使用不使用UserDetailsService的身份验证提供程序( 例如LDAP提供程序 ),那么它将不起作用,除非您在应用程序上下文中还具有UserDetailsService Bean。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.