Spring security Spring安全会话固定保护=";无”;在身份验证请求之前需要HTTP页

Spring security Spring安全会话固定保护=";无”;在身份验证请求之前需要HTTP页,spring-security,Spring Security,我不得不在我的应用程序(基于表单的登录)中使用session fixture protection=“none”,因为我必须在https(用于登录)和http(用于所有其他页面)之间切换,当我直接深入登录页面(https)或从另一个https页面登录时遇到问题。主要的问题似乎是,我必须先从http页面开始,然后是我的登录页面(https页面),然后它正确地登录到默认的目标url页面(http页面)。如果我直接转到https登录页面,我会得到下面的异常(请参阅调试跟踪),登录页面会在http协议下

我不得不在我的应用程序(基于表单的登录)中使用session fixture protection=“none”,因为我必须在https(用于登录)和http(用于所有其他页面)之间切换,当我直接深入登录页面(https)或从另一个https页面登录时遇到问题。主要的问题似乎是,我必须先从http页面开始,然后是我的登录页面(https页面),然后它正确地登录到默认的目标url页面(http页面)。如果我直接转到https登录页面,我会得到下面的异常(请参阅调试跟踪),登录页面会在http协议下重新显示,然后我可以通过http登录,但它是通过http的。有人知道这是为什么吗

配置:

<beans:beans
    xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context"
    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/util
    http://www.springframework.org/schema/util/spring-util-3.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    <context:annotation-config />
    <context:component-scan base-package="dc" />
    <global-method-security />
    <http access-denied-page="/auth/denied.html">
         <intercept-url filters="none" pattern="/javax.faces.resource/**" />
         <intercept-url filters="none" pattern="/services/rest-api/1.0/**" />
         <intercept-url filters="none" pattern="/preregistered/*"/>
         <intercept-url
            pattern="/**/*.xhtml"
            access="ROLE_NONE_GETS_ACCESS" />
         <intercept-url
            pattern="/auth/*"
            access="ROLE_ANONYMOUS,ROLE_USER"/>
         <intercept-url
            pattern="/preregistered/*"
            access="ROLE_ANONYMOUS,ROLE_USER"/>
         <intercept-url
            pattern="/registered/*"
            access="ROLE_USER"
            requires-channel="http"/>
        <form-login
            login-processing-url="/j_spring_security_check.html"
            login-page="/auth/login.html"
            default-target-url="/registered/home.html"
            authentication-failure-url="/auth/login.html" />
         <logout invalidate-session="true" 
              logout-url="/auth/logout.html" 
              success-handler-ref="DCLogoutSuccessHandler"/>
        <anonymous username="guest" granted-authority="ROLE_ANONYMOUS"/>
        <custom-filter after="FORM_LOGIN_FILTER" ref="xmlAuthenticationFilter" />
        <session-management session-fixation-protection="none"/>
    </http>
    <!-- Configure the authentication provider -->
    <authentication-manager alias="am">
        <authentication-provider user-service-ref="userManager">
                <password-encoder ref="passwordEncoder" />
        </authentication-provider>
        <authentication-provider ref="xmlAuthenticationProvider" />
    </authentication-manager>
</beans:beans> 


如果您还没有添加以下侦听器,或许可以尝试添加

<listener>
    <listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
</listener> 

org.springframework.security.ui.session.HttpSessionEventPublisher

这里的第二个选项修复了我的情况:


是的,我现在已经配置好了,但问题相同。我得到auth/login.html;注销并尝试重新登录后,登录表单url地址上的jsessionid=6223D4A350010EA78CAF6DDB1E8E5510。如果我再次尝试(注销后第二次),我会进入。我注意到的一件事是当我注销并转到https上的auth/login.html页面im时,这是正确的。然后我尝试登录,但登录失败,然后在http上即时通信,并在原始问题(调试跟踪)中发布更新,有什么想法吗?您应该始终将代码粘贴在此处,以防您引用的文章被删除。现在发生了这种情况:(
<listener>
    <listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
</listener>