I want to pass some parameters with login details to spring security such as some item id. then after i want to redirect to page according to the user type. For this i am using custom filter to send additional parameter. And to redirection i am using authentication-success-handler-ref. My problem is, I am geting position conflict as i am using along with custom filter. Please help me out to do my task.
Here is my configuration
<http use-expressions="true">
<intercept-url pattern="/login" access="permitAll" />
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/logout" access="permitAll" />
<intercept-url pattern="/accessdenied" access="permitAll" />
<custom-filter ref="ddAuthenticationFilter" position="FORM_LOGIN_FILTER" />
<form-login authentication-failure-url="/accessdenied"
authentication-success-handler-ref="ddAuthenticationSuccessHandler"/>
</http>
<beans:bean id="ddAuthenticationFilter" class="com.dd.security.ExUsernamePasswordAuthenticationFilter"/>
<beans:bean id="ddAuthenticationSuccessHandler" class="com.dd.security.DDAuthenticationSuccessHandler" />
I understood your question as follows: I want to submit an itemId in the form login which is used after a successful login for redirection.
In order to establish such a process you need to do following things.
Remove
<form-login ...>
from your configuration. You should have:Don't forget to add a
<security:logout />
for logout and theentry-point-ref
attribute points to anauthenticationEntryPoint
.Add a
LoginUrlAuthenticationEntryPoint
forentry-point-ref
which points to your login page:Refactor your
ddAuthenticationFilter
to meet the following configuration:Create a new class
CustomWebAuthenticationDetailsSource
:and the related
CustomWebAuthenticationDetails
:Your
ddAuthenticationSuccessHandler
should have a similiar logic like in this example:A working example can be found here