I have a web application using spring security in order to manage authentication. My client has 2 login forms, my spring security config is as follows:
<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>
The first form-login element works fine i.e. i am able to login from the /user/login URL.
However, when i try to login from the second url /user/relogin, i get a 415:unsupported media type response from the server.
Note that if i switch the two elements, the one that is on top works fine and the bottom one results in a 415 response.
I did as suggested in the selected answer, my configuration now looks like this:
<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>
auto-config="true"andcreate-session="always"?