【问题标题】:HttpSessionStorage - Message not found in SESSIONHttpSessionStorage - 在 SESSION 中找不到消息
【发布时间】: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


    【解决方案1】:

    所以在搜索了一些答案后,我从这个问题中找到了答案 Spring SAML sending wrong AuthNRequest

    主要问题来自 SAMLContextProviderLB 它与 Spring Session 冲突。

    这行代码对我有用。

    samlContextProviderLB.setStorageFactory(new EmptyStorageFactory());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 1970-01-01
      • 2021-09-21
      • 1970-01-01
      • 1970-01-01
      • 2010-09-15
      相关资源
      最近更新 更多