0
我嘗試了所有解決方案。我面臨的2個問題:春季安全:註銷時總是重定向到invalid-session-url
- 註銷重定向即使當應用程序被註銷無效會話的URL
- ,會話超時事件保持在每一個設定的時間間隔重複(比如10分鐘)。這會導致登錄頁面提交操作(登錄按鈕)重定向到invalid-session-url。所以如果我註銷,並嘗試登錄10分鐘後(這是會話超時間隔),登錄頁面再次重定向登錄?logout = 1(invalid-session-url),而不是登錄應用程序。之後,我可以登錄。
以下是我所做的修改之後,我面臨的上述問題:
- 我改變從HTTP模式/登錄頁面訪問=「/登錄」 安全=「無」到intercept-url pattern =「/ login」 access =「isAnonymous()」來實現csrf。我試過 切換訪問許可以及。
- 我已經在瀏覽器中觀察到,每次我退出的時候,當前 JSESSIONID被丟棄,新JSESSIONID在瀏覽器中創建的,註銷操作重定向到無效會話的URL代替 註銷成功的網址。
- 再次登錄,作爲新 創建JSESSIONID註銷後JSESSIONID保持不變。它不應該改變嗎?
下面是安全性方面的配置:
<http pattern="/" security="none"/>
<!--<http pattern="/login" security="none"/>-->
<http pattern="/resources/assets/**" security="none"/>
<http pattern="/resources/bootstrap/**" security="none"/>
<http pattern="/resources/config/**" security="none"/>
<http pattern="/resources/css/**" security="none"/>
<http pattern="/resources/data/**" security="none"/>
<http pattern="/resources/font-awesome-4.5.0/**" security="none"/>
<http pattern="/resources/fonts/**" security="none"/>
<http pattern="/resources/images/**" security="none"/>
<http auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint">
<!--permitall isAnonymous()-->
<intercept-url pattern="/login" access="isAnonymous()" />
<intercept-url pattern="/login?logout=1" access="isAnonymous()" />
<intercept-url pattern="/login?logout=0" access="isAnonymous()" />
<intercept-url pattern="/login?logout=2" access="isAnonymous()" />
<intercept-url pattern="/login?error" access="isAnonymous()" />
<intercept-url pattern="/**" access="isAuthenticated()" />
<intercept-url pattern="/user/*" access="isAuthenticated()" />
<intercept-url pattern="/resources/js/angular/**" access="isAuthenticated()" />
<custom-filter position="FORM_LOGIN_FILTER" ref="customUsernamePasswordAuthenticationFilter" />
<logout logout-success-url="/login?logout=0" invalidate-session="true" delete-cookies="JSESSIONID" />
<!--<logout success-handler-ref="customLogoutSuccessHandler" invalidate-session="true" delete-cookies="JSESSIONID"
newSession/>-->
<session-management invalid-session-url="/login?logout=1" session-fixation-protection="migrateSession">
<concurrency-control max-sessions="1" expired-url="/login?logout=2" />
</session-management>
<csrf/>
<headers/>
</http>
<beans:bean id="loginUrlAuthenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<beans:property name="loginFormUrl" value="/login"/>
</beans:bean>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="customAuthenticationProvider"/>
</authentication-manager>
<beans:bean id="customUsernamePasswordAuthenticationFilter"
class="com.vitrana.hilit.web.security.CustomAuthenticationFilter" >
<beans:property name="authenticationManager" ref="authenticationManager"/>
<beans:property name="authenticationFailureHandler" ref="failureHandler"/>
<beans:property name="authenticationSuccessHandler" ref="successHandler"/>
<beans:property name="usernameParameter" value="hdnUserName" />
<beans:property name="passwordParameter" value="password" />
</beans:bean>
<beans:bean id="successHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<beans:property name="defaultTargetUrl" value="/user/dashboard.jsp"/>
</beans:bean>
<beans:bean id="failureHandler" class="com.vitrana.hilit.web.security.UserNameCachingAuthenticationFailureHandler">
<beans:property name="defaultFailureUrl" value="/login?error"/>
</beans:bean>
<beans:bean id="customLogoutSuccessHandler" class="com.vitrana.hilit.web.security.CustomLogoutSuccessHandler" > </beans:bean>
<beans:bean class="com.vitrana.hilit.web.security.SessionDestroyedListener">
</beans:bean>
請建議。任何幫助表示讚賞。 謝謝
你可以在這裏找到你的解決方案http://stackoverflow.com/questions/7391735/difference-between-access-permitall-and-filters-none – Innocuous
我已經嘗試了所有這些。沒有工作。我無法添加filters = none,因爲我在頁面上使用了安全性taglib和csrf。請提出一些其他解決方案。 – Curiousreed
您是否嘗試從''元素中移除'invalidate-session =「true」'? –
jlumietu