Web applications Spring安全性和多个登录表单
我有一个使用spring security的web应用程序来管理身份验证。 我的客户端有2个登录表单,我的spring安全配置如下:Web applications Spring安全性和多个登录表单,web-applications,spring-security,Web Applications,Spring Security,我有一个使用spring security的web应用程序来管理身份验证。 我的客户端有2个登录表单,我的spring安全配置如下: <http auto-config="true" use-expressions="true" create-session="always"> <intercept-url pattern="/**" access="permitAll" /> <form-login login-processi
<http auto-config="true" use-expressions="true" create-session="always">
<intercept-url pattern="/**" access="permitAll" />
<form-login login-processing-url="/user/login" login-page="/user/login/unauthorized"
default-target-url="/user/firstLogin" authentication-failure-url="/user/login/failure" />
<form-login login-processing-url="/user/relogin" login-page="/user/login/unauthorized"
default-target-url="/user/reLoginFromClient" authentication-failure-url="/user/login/failure" />
<logout logout-url="/user/logout/spring" logout-success-url="/user/logout/success" />
<access-denied-handler ref="accessDeniedHandler"/>
</http>
不能在单个
元素中使用多个
元素
相反,您可以通过定义UsernamePasswordAuthenticationFilter
bean并使用customfilter
元素插入它来使用一个并添加第二个
您可能还应该删除
自动配置
。很少需要为每个请求创建会话,因此我也会删除create session
属性,除非您确定需要它。您不能在单个
元素中使用多个
元素
相反,您可以通过定义UsernamePasswordAuthenticationFilter
bean并使用customfilter
元素插入它来使用一个并添加第二个
您可能还应该删除
自动配置
。很少需要为每个请求创建会话,因此我也会删除create session
属性,除非您确定需要它。谢谢Luke,我将尝试UsernamePasswordAuthenticationFilter。谢谢Luke,我将尝试UsernamePasswordAuthenticationFilter。出于好奇,您使用auto-config=“true”
和create session=“always”
的原因是什么?@Luke,可能没有。在删除它们之前,我需要先验证一下。出于好奇,您使用auto-config=“true”
和create-session=“always”
?@Luke的原因是什么?可能没有。在删除它们之前,我需要首先对此进行验证。
<http auto-config="true" use-expressions="true" create-session="always" authentication-manager-ref="authenticationManager">
<intercept-url pattern="/**" access="permitAll" />
<custom-filter after="SECURITY_CONTEXT_FILTER" ref="reLoginFilter"/>
<form-login login-processing-url="/user/login" login-page="/user/login/unauthorized"
default-target-url="/user/firstLogin" authentication-failure-url="/user/login/failure" />
<logout logout-url="/user/logout/spring" logout-success-url="/user/logout/success" />
<access-denied-handler ref="accessDeniedHandler"/>
</http>
<beans:bean id="reLoginFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<beans:property name="authenticationManager" ref="authenticationManager"/>
<beans:property name="filterProcessesUrl" value="/user/relogin"/>
<beans:property name="authenticationSuccessHandler" ref="authenticationSuccessHandler" />
<beans:property name="authenticationFailureHandler" ref="authenticationFailHandler" />
</beans:bean>
<beans:bean id="authenticationSuccessHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler">
<beans:property name="defaultTargetUrl" value="/user/relogin/success"/>
</beans:bean>
<beans:bean id="authenticationFailHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<beans:property name="defaultFailureUrl" value="/user/login/failure"/>
</beans:bean>