spring session 内部是否需要使用spring security?
现在,我们有一个现有的应用程序,它使用来自 servlet 容器(例如 WebLogic)的 HTTP 会话。由于会话复制方面的一些问题以及未来使用另一个 servlet 容器的计划,我们决定寻找能够使 HTTP 会话容器独立的现有框架。
该团队决定将 Spring Session 与 Hazelcast 结合使用,如官方文档中所述。我们使用 spring session 版本 1.3.5.RELEASE。
对于 hazelcast 配置,我们使用此会话配置。
<context:annotation-config/>
<bean class="org.springframework.session.hazelcast.config.annotation.web.http.HazelcastHttpSessionConfiguration"/>
<bean id="hazelcastInstance" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="xxx.xxx.xxx.cache.CustomHazelcastProvider.getInstance"/>
</bean>
<bean class="org.springframework.session.web.http.SessionEventHttpSessionListenerAdapter">
<constructor-arg>
<list>
<bean class="xxx.xxx.xxx.util.CustomHttpSessionListener"/>
</list>
</constructor-arg>
</bean>
<bean class="org.springframework.session.web.http.DefaultCookieSerializer">
<property name="cookieName" value="JSESSIONID"/>
<property name="cookiePath" value="/"/>
<property name="domainNamePattern" value="^.+?\.(\w+\.[a-z]+)$"/>
</bean>
在 web.xml 中,我们放置了这个过滤器链。
<filter>
<filter-name>springSessionRepositoryFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSessionRepositoryFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>CustomServletRequestFilter</filter-name>
<filter-class>xxx.xxx.xxx.servlet.filter.CustomServletRequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CustomServletRequestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
并在 web.xml 下面添加了 spring 配置
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:application-context.xml</param-value>
</context-param>
在同一个 web.xml 中,我们使用基于表单的身份验证。
<login-config>
<auth-method>FORM</auth-method>
<realm-name>myrealm</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/loginerror.html</form-error-page>
</form-login-config>
</login-config>
此外,我们使用默认的基于 cookie 的 HTTP 策略。
在 weblogic 中部署上述更改后,我们能够成功登录。能够检查来自春季会话的会话 ID。但是,下一跳或后续的 REST 调用,它总是返回 HTTP 302。它被重定向到登录页面。
spring session 是否需要使用 spring security?是否需要添加一些配置来解决此问题?
将不胜感激任何帮助或建议来解决此问题。
谢谢你。