【发布时间】:2011-09-28 05:50:13
【问题描述】:
我需要使用 2 层来保护我的网站。首先是 LDAP 检查,接下来是用户名/密码条目。我已经为这两项检查编写了两个自定义身份验证过滤器。
如果 LDAP 过滤器失败,则应将用户重定向到“拒绝访问”页面,如果用户名/密码失败,则应将用户重定向回登录页面。
如何在我的 config.xml 文件中设置这些过滤器?这是我目前拥有的
<sec:http entry-point-ref="loginAuthenticationEntryPoint"
auto-config="false" use-expressions="true">
<sec:intercept-url pattern="/login.htm" access="isAnonymous()" />
<sec:intercept-url pattern="/*"
access="hasRole('ROLE_LDAP') and hasRole('ROLE_CRESTA')" />
<sec:custom-filter ref="ldapAuthenticationFilter"
before="FORM_LOGIN_FILTER" />
<sec:custom-filter ref="usernameAuthenticationFilter"
position="FORM_LOGIN_FILTER" />
</sec:http>
与
public class LdapAuthenticationFilter extends AbstractPreAuthenticatedProcessingFilter
和
public class CrestaUsernameAuthenticationFilter extends AbstractAuthenticationProcessingFilter
我目前的想法是让每个过滤器添加一个所需的角色,但是当 LDAP 过滤器没有添加这两个角色时,我会立即被拒绝访问。
非常感谢
【问题讨论】:
标签: java spring-security servlet-filters