Results 1 to 4 of 4

Thread: Redirect Loop Help

  1. #1
    Join Date
    Sep 2010
    Location
    Boise, Idaho, USA
    Posts
    5

    Default Redirect Loop Help

    Hi, I think I need some fresh eyes. I've been trying to figure out why I'm receiving a redirect-loop when trying to access my login page and am at my wits' end. Any help would be appreciated. Here's my security.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    	xmlns:beans="http://www.springframework.org/schema/beans" 
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://www.springframework.org/schema/security
               http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">
    	
    	<!-- START filterChainProxy ****************************************************************-->
    	<beans:bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
    		<filter-chain-map path-type="ant">
    			<filter-chain pattern="/services/**" filters="securityContextPersistenceFilterWithASCFalse,
    														  digestFilter,
    														  exceptionTranslationFilter,
    														  filterSecurityInterceptor" />
    			<filter-chain pattern="/**" filters="securityContextPersistenceFilterWithASCTrue,
    												 usernamePasswordAuthenticationFilter,
    												 exceptionTranslationFilter,
    												 filterSecurityInterceptor" />
    		</filter-chain-map>
    	</beans:bean>
    	<!-- END ***********************************************************************************-->
    	
    	<!-- START securityContextPersistenceFilterWithASCFalse ************************************-->
    	<beans:bean id="securityContextPersistenceFilterWithASCFalse" 
    				class="org.springframework.security.web.context.SecurityContextPersistenceFilter">
    		<beans:property name="securityContextRepository">
    			<beans:bean class="org.springframework.security.web.context.HttpSessionSecurityContextRepository">
    				<beans:property name="allowSessionCreation" value="false"/>
    			</beans:bean>
    		</beans:property>
    	</beans:bean>
    	<!-- END ***********************************************************************************-->
    	
    	<!-- START securityContextPersistenceFilterWithASCTrue *************************************-->
    	<beans:bean id="securityContextPersistenceFilterWithASCTrue" 
    				class="org.springframework.security.web.context.SecurityContextPersistenceFilter">
    		<beans:property name="securityContextRepository">
    			<beans:bean class="org.springframework.security.web.context.HttpSessionSecurityContextRepository">
    				<beans:property name="allowSessionCreation" value="true"/>
    			</beans:bean>
    		</beans:property>
    	</beans:bean>
    	<!-- END ***********************************************************************************-->
    	
    	<!-- START  exceptionTranslationFilter *****************************************************-->
    	<beans:bean id="exceptionTranslationFilter"
         			class="org.springframework.security.web.access.ExceptionTranslationFilter">
       		<beans:property name="authenticationEntryPoint" ref="authenticationEntryPoint"/>
       		<beans:property name="accessDeniedHandler" ref="accessDeniedHandler"/>		
        </beans:bean>
        
        <beans:bean id="authenticationEntryPoint"
         	  		class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
      		<beans:property name="loginFormUrl" value="/index.htm"/>
    	</beans:bean>
    
    	<beans:bean id="accessDeniedHandler"
         	  		class="org.springframework.security.web.access.AccessDeniedHandlerImpl">
      		<beans:property name="errorPage" value="/accessDenied.htm"/>
    	</beans:bean>
    	<!-- END ***********************************************************************************-->
    	
    	<!-- START filterSecurityInterceptor *******************************************************-->
    	<beans:bean id="filterSecurityInterceptor"
            		class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
    		<beans:property name="authenticationManager" ref="authenticationManager"/>
    		<beans:property name="accessDecisionManager" ref="accessDecisionManager"/>
    		<beans:property name="securityMetadataSource">
    			<filter-security-metadata-source>
    				<intercept-url pattern="/*.htm" access="IS_AUTHENTICATED_ANONYMOUSLY" />
    				<intercept-url pattern="/hair/*" access="ROLE_USER" />
    				<intercept-url pattern="/**" access="ROLE_ADMIN"/>
    			</filter-security-metadata-source>
    		</beans:property>
    	</beans:bean>
    	
    	<authentication-manager alias="authenticationManager">
    		<authentication-provider user-service-ref="userDao">
    			<password-encoder ref="passwordEncoder"/>
     		</authentication-provider>
    	</authentication-manager>
    	
    	<beans:bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased">
    		<beans:property name="decisionVoters">
    			<beans:list>
    				<beans:bean class="org.springframework.security.access.vote.AuthenticatedVoter"/>
    				<beans:bean class="org.springframework.security.access.vote.RoleVoter" />
    			</beans:list>
    		</beans:property>
    	</beans:bean>
    	<!-- END ***********************************************************************************-->
    	
    	<!-- START usernamePasswordAuthenticationFilter ********************************************-->
    	<beans:bean id="usernamePasswordAuthenticationFilter" 
    		 		class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
    		<beans:property name="authenticationManager" ref="authenticationManager"/>
    	</beans:bean>
    	<!-- END ***********************************************************************************-->
    	
    	<!-- START digestFilter ********************************************************************-->
    	<beans:bean id="digestFilter" class="org.springframework.security.web.authentication.www.DigestAuthenticationFilter">
    		<beans:property name="userDetailsService" ref="userDao"/>
    		<beans:property name="authenticationEntryPoint" ref="digestEntryPoint"/>
    	</beans:bean>
    	
    	<beans:bean id="digestEntryPoint" class="org.springframework.security.web.authentication.www.DigestAuthenticationEntryPoint">
    		<beans:property name="realmName" value="Contacts Realm via Digest Authentication"/>
    		<beans:property name="key" value="acegi"/>
    		<beans:property name="nonceValiditySeconds" value="300"/>
    	</beans:bean>
    	
    	<!-- END ***********************************************************************************-->
    </beans:beans>

  2. #2
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Check the FAQ entry, and then turn on debug logging and post the results here. We'll try to help you out. Please provide specifics on (1) what URL the user tries to access, (2) what URL represents the login form, (3) what your login form POSTs to, and (4) what version of Spr Sec you're using.

    Thanks!
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  3. #3
    Join Date
    Sep 2010
    Location
    Boise, Idaho, USA
    Posts
    5

    Default

    Thanks for the lead pmularien, i didn't even think to switch org.springframework.security logging to DEBUG. Turns out I was missing an instance of org.springframework.security.web.authentication.An onymousAuthenticationFilter. I added the bean in my security.xml and the redirect issue was solved.

  4. #4
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Great! Glad you figured it out
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •