【问题标题】:Springboot SAML integration fails on Google App Engine, InResponseToField doesn't correspond to sent messageGoogle App Engine 上的 Springboot SAML 集成失败,InResponseToField 与发送的消息不对应
【发布时间】:2018-07-23 07:20:17
【问题描述】:

我为我的组织创建了一个 Springboot Restful 应用程序。 我有一个要求,

  1. 使用 IdP (ADFS2.0) 实施 SAML/SSO,
  2. 在 Google 的 App Engine (GAE) 上部署应用程序。

我已成功在 GAE(使用 SAML)上部署 Springboot 应用程序。

我已经在本地主机上使用 IdP 的 Mock 版本(类似于 SSO-Circle)测试了 SAML/SSO,它运行顺利。

但是,当我在 GAE 上部署应用程序时(使用 IdP 的 Mock 版本或 IdP 的 QA 版本),我开始得到 ​​p>

InResponseToField 与发送的消息不对应

,我确实在 Spring 文档 here 中找到了解决方法。

但是, 即使经过大量调试,我也无法理解为什么我首先会收到该错误(尽管在应用修复后我会收到不同的错误,我将在稍后进一步描述)。

当我查看 App Engine 日志时,我发现了很多令人困惑的部分,

  1. 在进行 /saml/login 调用时,日志跟踪显示

HttpSessionStorage : 将消息 a3bbxxxx6c17 存储到 会话 BXtxxxx1CCw

  1. 然后当 IdP 重定向回端点 /saml/SSO 上的应用程序时,日志会抛出错误,

HttpSessionStorage:消息 a3bbxxxx6c17 未在 会话 BXtxxxx1CCw

除了例外

SAMLException:响应的 InResponseToField 不对应 发送消息a3bbxxxx6c17

  1. 我还交叉验证了从应用程序发出到 IdP 的 SAML 请求 (XML) 和从 IdP 返回到应用程序的 SAML 响应 (XML),它们都有 a3bbxxxx6c17 消息。 那么,为什么 Springboot 在 GAE 上会感到困惑,并且在 localhost 上运行良好。

另外,当我按照 spring 文档所说的“检查 InResponseToField 可以通过重新配置上下文提供程序来禁用”时,我注意到发生了一个循环,即,

  1. /saml/login -> 2. /saml/SSO -> /landing -> 3. /saml/SSO -> /landing -> 4. /saml/SSO -> /landing -> 5. /saml/ SSO -> /landing .... 以此类推,直到 IdP 在短时间内拒绝请求太多请求。

我也不明白为什么会发生这种情况,但我的假设是这可能是由于上述问题。 有什么想法吗?

【问题讨论】:

    标签: google-app-engine spring-boot spring-saml


    【解决方案1】:

    通过添加额外配置解决了问题。

    发生这种情况的事实是 Spring 不知道 App Engine (GAE) 上的会话,我们需要做的就是告诉 spring。

        @Configuration
            @EnableWebSecurity
            //Needed for Spring to know about the HttpSession
            @EnableSpringHttpSession
            @EnableGlobalMethodSecurity(securedEnabled = true)
            public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    
        //And this bean
            @Bean
            public MapSessionRepository sessionRepository() {
                return new MapSessionRepository();
            }
       // all other configurations
            }
    

    【讨论】:

      猜你喜欢
      • 2022-08-19
      • 2017-12-25
      • 2018-02-28
      • 2019-11-25
      • 1970-01-01
      • 1970-01-01
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多