Announcement Announcement Module
Collapse
No announcement yet.
Sometimes Acegi doesn't redirect Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sometimes Acegi doesn't redirect

    I use Acegi security in my application and I have a strange behavour. In 3/4 cases I login, Acegi works fine. It means, when I want to enter mainpage "/gwt/ers.html", correct user name and password redirect me to it. But sometimes it redirects me to "/" and I don't know why. In both cases I have same message in Tomcat6 log file :
    "Authentication event InteractiveAuthenticationSuccessEvent: admin; details: org.acegisecurity.ui.WebAuthenticationDetails@fffe 9938: RemoteIpAddress: 62.219.114.237; SessionId: 02320784960802F1E92D1CACC161C813"
    Morever, if Acegi redirects me to "/" and I try to open ers.html page in same window it works.
    I think, the problem is, that Acegi doesn't remember my request, because "/" is defaultTargUrl in AuthenticationProccesingFilter. The obvisious solution is to set defaultTargetUrl to "/gwt/ers.html", but I want to understand what a problem. Is anybody can help me?

    Acegi in web.xml :
    Code:
                <listener>                <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
                </listener>
    
                <listener>                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
                </listener>
    
                <filter>
                  <filter-name>Acegi Filter Chain Proxy</filter-name>
                  <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
                  <init-param>
                  <param-name>targetClass</param-name>                                     <param-value>org.acegisecurity.util.FilterChainProxy</param-value>
                  </init-param>
                </filter>
    
                <filter>
                    <filter-name>requestContextFilter</filter-name>             <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
                </filter>
    
                <filter>
                    <filter-name>openSessionInView</filter-name>                <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
                </filter>
    
               <filter-mapping>
                    <filter-name>Acegi Filter Chain Proxy</filter-name>
                    <url-pattern>/gwt/*</url-pattern>
                   <url-pattern>/reports/*</url-pattern>
                   <url-pattern>/admin/*</url-pattern>
                   <url-pattern>/files/*</url-pattern>
               </filter-mapping>
    
                <filter-mapping>
                    <filter-name>requestContextFilter</filter-name>
                    <url-pattern>/gwt/*</url-pattern>
                    <url-pattern>/files/*</url-pattern>
                </filter-mapping>
    
                <filter-mapping>
                    <filter-name>openSessionInView</filter-name>
                    <servlet-name>ERService</servlet-name>
                    <servlet-name>SummaryFileService</servlet-name>
                    <dispatcher>REQUEST</dispatcher>
                    <dispatcher>FORWARD</dispatcher>
                    <dispatcher>INCLUDE</dispatcher>
                </filter-mapping>
           </web-app>
    Acegi in applicationContext-acegi-security.xml :
    Code:
    <beans>
        <bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy">
    		<property name="filterInvocationDefinitionSource">
                <value><![CDATA[
                    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    				PATTERN_TYPE_APACHE_ANT				/**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
    			]]></value>
    		</property>
    	</bean>
    
        <bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
    		<property name="authenticationManager" ref="authenticationManager"/>
    		<property name="authenticationFailureUrl" value="/gwt/login_error.html"/>
    		<property name="defaultTargetUrl" value="/"/>
    		<property name="filterProcessesUrl" value="/gwt/j_acegi_security_check"/>
    		<property name="rememberMeServices" ref="rememberMeServices"/>
    	</bean>
    
    	<bean id="rememberMeProcessingFilter" class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter">
    		<property name="authenticationManager" ref="authenticationManager"/>
    		<property name="rememberMeServices" ref="rememberMeServices"/>
    	</bean>
    
    	<bean id="anonymousProcessingFilter" class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter">
    		<property name="key" value="changeThis"/>
    		<property name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS"/>
    	</bean>
    
        <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
    		<property name="authenticationEntryPoint">
    			<bean class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
    				<property name="loginFormUrl" value="/gwt/acegilogin.html"/>
    				<property name="forceHttps" value="false"/>
    			</bean>
    		</property>
    <!--		<property name="accessDeniedHandler">
    			<bean class="org.acegisecurity.ui.AccessDeniedHandlerImpl">
    				<property name="errorPage" value="/gwt/accessDenied.jsp"/>
    			</bean>
    		</property> -->
    	</bean>
    
        <bean id="logoutFilter"
              class="org.acegisecurity.ui.logout.LogoutFilter">
    
              <constructor-arg value="/gwt/acegilogin.html" /><!-- URL redirected to after logout -->
    
              <constructor-arg>
                <list>
                    <ref bean="rememberMeServices"/> 
                  <bean
                        class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler" />
                </list>
              </constructor-arg>
              <property name="filterProcessesUrl" value="/gwt/j_acegi_logout"/>
        </bean>
    
        <bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
    		<property name="authenticationManager" ref="authenticationManager"/>
    		<property name="accessDecisionManager">
    			<bean class="org.acegisecurity.vote.AffirmativeBased">
    				<property name="allowIfAllAbstainDecisions" value="false"/>
    				<property name="decisionVoters">
    					<list>
    						<bean class="org.acegisecurity.vote.RoleVoter"/>
    						<bean class="org.acegisecurity.vote.AuthenticatedVoter"/>
    					</list>
    				</property>
    			</bean>
    		</property>
    		<property name="objectDefinitionSource">
                <!-- -->
                <value><![CDATA[
    			    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    				PATTERN_TYPE_APACHE_ANT
    /gwt/j_acegi_security_check=ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_SECTION,ROLE_USER,IS_AUTHENTICATED_REMEMBERED	/gwt/j_acegi_logout=ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_SECTION,ROLE_USER,IS_AUTHENTICATED_REMEMBERED	/gwt/acegilogin.html=ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_SECTION,ROLE_USER	/gwt/logo.png=ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_SECTION,ROLE_USER		/gwt/**=ROLE_ADMIN,ROLE_SECTION,ROLE_USER,IS_AUTHENTICATED_REMEMBERED	/repots/**=ROLE_ADMIN,ROLE_SECTION,ROLE_USER,IS_AUTHENTICATED_REMEMBERED	/files/**=ROLE_ADMIN,ROLE_SECTION,ROLE_USER,IS_AUTHENTICATED_REMEMBERED	/admin/**=ROLE_ADMIN,ROLE_SECTION,ROLE_USER,IS_AUTHENTICATED_REMEMBERED
    			]]></value>
    		</property>
    	</bean>
    
    	<bean id="rememberMeServices" class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices">
    		<property name="userDetailsService" ref="userDetailsDaoService"/>
            <property name="key" value="changeThis"/>
    	</bean>
    </beans>
    acegilogin.html :
    Code:
    <html>
      <body>
        <form method="POST" action="j_acegi_security_check">               
                    <!-- Login dialogs table -->
                    <table align="center" width="80%">
                        <tr>
                            <td align="left">Username:</td><td><input type="text" name="j_username" id="j_username"></td>
                        </tr>
                        <tr>
                             <td align="left">Password:</td><td align="left">                            <input type="password" name="j_password" id="j_password">                      </td>
                      </tr>
                        <tr>
                            <td><input type="checkbox" name="_acegi_security_remember_me"></td>
                        </tr>
                        <tr>
                            <td align="left" colspan="2"><input type="submit" value="Log in >>">&nbsp;                            <input name="reset" type="reset" value="Clear"></td>
                        </tr>
                    </table>
        </form>
      </body>
    </html>

  • #2
    Enable debug logging for Acegi and follow the log messages. They will give a pretty comprehensive commentary on how each request is being handled.

    Comment

    Working...
    X