【发布时间】:2021-12-22 09:36:11
【问题描述】:
我能够使用 Spring Security SAML 将 单点登录 集成到我的 Web 应用程序中。但是我在添加这个依赖org.springframework.session时遇到了问题。
首先它将数据存储到会话中,然后重定向到 IDP。
DEBUG o.s.s.s.storage.HttpSessionStorage - Storing message a4850861j4f289ha850h8gh92hj85d to session c5a13884-37d5-4e3d-b5ec-44ac6013de7a
认证成功后,由于id发生变化,无法从SESSION中找到存储的数据。
DEBUG o.s.s.s.storage.HttpSessionStorage - Message a4850861j4f289ha850h8gh92hj85d not found in session 6c84d9a8-2c78-4e3b-8726-4f8129e9a543
DEBUG o.s.s.s.SAMLAuthenticationProvider - Error validating SAML message
org.opensaml.common.SAMLException: InResponseToField of the Response doesn't correspond to sent message a4850861j4f289ha850h8gh92hj85d
添加依赖项时会覆盖创建的会话名称"mujinaSpSessionId"。
@Bean
public ServletContextInitializer servletContextInitializer() {
//otherwise the two localhost instances override each other session
return servletContext -> {
SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
sessionCookieConfig.setName("mujinaSpSessionId");
sessionCookieConfig.setSecure(this.secureCookie);
sessionCookieConfig.setHttpOnly(true);
};
}
作为参考,我正在关注 Mujina 的实现,这里是代码 WebSecurityConfigurer.java 的链接。
任何答案都会有所帮助,谢谢!
【问题讨论】:
标签: java spring-boot spring-security spring-session