Spring Security 条件 default-target-url
2022-09-04 01:35:48
我注意到有几个问题询问这个话题。我查看了它们,我无法将它们应用于我特定的Spring设置。我想根据用户的角色将我的登录重定向配置为有条件的。这是我到目前为止所拥有的:
<http auto-config="true" use-expressions="true">
<custom-filter ref="filterSecurityInterceptor" before="FILTER_SECURITY_INTERCEPTOR"/>
<access-denied-handler ref="accessDeniedHandler"/>
<form-login
login-page="/login"
default-target-url="/admin/index"
authentication-failure-url="/index?error=true"
/>
<logout logout-success-url="/index" invalidate-session="true"/>
</http>
我认为这个问题可能与我试图做的事情是一致的。有谁知道我该如何应用它?
编辑 1
<bean id="authenticationProcessingFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<property name="authenticationManager" ref="authenticationManager" />
<property name="authenticationSuccessHandler" ref="authenticationSuccessHandler"/>
</bean>
<bean id="authenticationSuccessHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler">
<property name="defaultTargetUrl" value="/login.jsp"/>
</bean>
编辑 2
目前,我没有此示例中所示的类。public class Test implements AuthenticationSuccessHandler {}