Announcement Announcement Module
Collapse
No announcement yet.
alwaysUseDefaultTargetUrl not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • alwaysUseDefaultTargetUrl not working

    Hello everyone,
    I am using Spring security 3.1 and i have set alwaysUseDefaultTargetUrl to false but after login it always redirects to defaultTargetURL page.
    It works fine with security:form-login but not if i use custom-filter for processing.
    Code:
    <security:http entry-point-ref="authenticationProcessingFilterEntryPoint" access-denied-page="/resources/jsp/accessDeniedPage.jsp">
    	<security:custom-filter ref="customAuthenticationProcessingFilter" position="FORM_LOGIN_FILTER" />
    	...
    </security:http>
    
    
    <bean id="customAuthenticationProcessingFilter" class="..">
    	...
    	<property name="authenticationFailureHandler" ref="authenticationFailureHandler"/>
    	<property name="authenticationSuccessHandler" ref="authenticationSuccessHandler"/>
    </bean>
    <bean id="authenticationSuccessHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler">
    	<property name="defaultTargetUrl" value="/home.htm"/>
    	<property name="alwaysUseDefaultTargetUrl" value="false"/>
    </bean>
    Have I done anything wrong?
    Last edited by vikrant chavan; May 20th, 2011, 08:17 AM.

  • #2
    Since it is your custom class which is doing the authentication processing, it is impossible to say. If it works with the standard filter, then my best guess is that it's something you have changed in your code.

    Comment


    • #3
      I just replaced
      Code:
      <security:form-login 	login-page="/signIn.htm" 
      			default-target-url="/home.htm"
      		    	always-use-default-target="false" 
      			login-processing-url="/j_spring_security_check"
      		    	authentication-failure-url="/signIn.htm" />
      by
      Code:
      <security:custom-filter ref="customAuthenticationProcessingFilter" position="FORM_LOGIN_FILTER" />
      and added
      Code:
      <bean id="customAuthenticationProcessingFilter" class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
      	<property name="filterProcessesUrl" value="/j_spring_security_check" />
      	<property name="authenticationManager" ref="authenticationManagerAlias"/>
      	<property name="sessionAuthenticationStrategy" ref="sas" />
      	<property name="messageSource" ref="messageSource"/>
      			
      	<property name="authenticationFailureHandler" ref="authenticationFailureHandler"/>
      	<property name="authenticationSuccessHandler" ref="authenticationSuccessHandler"/>
      </bean>
      <bean id="authenticationSuccessHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler">
      	<property name="defaultTargetUrl" value="/home.htm"/>
      	<property name="alwaysUseDefaultTargetUrl" value="false"/>
      </bean>
      <bean id="authenticationFailureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
      	<property name="defaultFailureUrl" value="/signIn.htm"/>
      </bean>

      Comment


      • #4
        Ok, then it looks like you need to use SavedRequestAwareAuthenticationSuccessHandler instead of SimpleUrlAuthenticationSuccessHandler, as the latter has no awareness of cached requests.

        Comment


        • #5
          Thanks, it worked

          Comment

          Working...
          X