0

我有一个带有弹簧安全性的网络项目。我有不同的角色,例如 ROLE_ADMIN、ROLE_USER、ROLE_TESTER、ROLE_ANONYMOUS,具有不同的拦截 URL,例如:

<intercept-url pattern="/secure/admin/**" access="ROLE_ADMIN" />
<intercept-url pattern="/secure/**" access="ROLE_USER,ROLE_ADMIN" />
<intercept-url pattern="/**" access="ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN" />

现在,如果有人试图访问 /secure/admin/user/list.mvc,我希望他被重定向到另一个登录表单,而不是正常的登录表单:

<form-login  login-processing-url="/j_spring_security_check" login-page="/start.mvc"
       authentication-success-handler-ref="authenticationSuccessHandler"
       authentication-failure-handler-ref="authenticationFailureHandler" 
/>

有没有可能这样做?

4

1 回答 1

0

使用 Spring Security >= 3.1,您可以拥有多个http类似于此的元素:

<!-- Configure realm for system administration users -->
<security:http pattern="/secure/admin/**" create-session="stateless">
    <security:intercept-url pattern="/**" access='ROLE_ADMIN' requires-channel="https" />
    ...form login... etc
</security:http>


<!-- Configure realm for standard users -->
<security:http auto-config="true" access-denied-page="/error/noaccess" use-expressions="true" create-session="ifRequired">
    <security:form-login login-page="/login"
            ...
            ...
</security:http>
于 2013-02-14T12:25:50.180 回答