【发布时间】:2016-05-05 11:27:47
【问题描述】:
我在https://biz.dev.originsystems.co.za 设置了一个服务提供商。我在 http://stage.originsystems.co.za 设置了 IdP。
使用https://biz.dev.originsystems.co.za/simplesaml/module.php/core/authenticate.php 的工具测试身份验证时,一切正常。它带着所需的属性返回到开发站点,一切都很快乐。
但是,当我尝试在 https://biz.dev.originsystems.co.za 上的代码中实际点击 IdP 时,我被重定向到 Stage 登录页面,但登录后出现“状态信息丢失”错误。我得到以下调试信息:
SimpleSAML_Error_NoState: NOSTATE
Backtrace:
2 /webdevroot/Updraft/web/external/System/SSO/simplesaml/lib/SimpleSAML/Auth/State.php:225 (SimpleSAML_Auth_State::loadState)
1 /webdevroot/Updraft/web/external/System/SSO/simplesaml/modules/saml/www/sp/saml2-acs.php:63 (require)
0 /webdevroot/Updraft/web/external/System/SSO/simplesaml/www/module.php:134 (N/A)
我已完成页面要求我执行的所有故障排除,但情况仍然存在。
我在浏览器上打开了开发工具并查看了 cookie 信息。 biz.dev.originsystems.co.za 的 cookie 包含一个 SimpleAMLAuthToken,所以我认为这些 cookie 可以正常工作。我用来打 IdP 的代码是:
$as = new SimpleSAML_Auth_Simple("stage-sso-sp");
$as->requireAuth();
$attributes = $as->getAttributes();
print_r($attributes);
更新:
这里有更多信息...
我想确定问题是否与我设置 IdP 的方式有关,因此我开始为 IdP 使用 SSO Circle。在 SSO Circle 上进行身份验证后,状态信息也会丢失。我认为这意味着问题出在我的 SimpleSAML 服务提供商设置的某个地方。这就是正在发生的事情......
当我转到 https://biz.stage.originsystems.co.za/simplesaml 的 SimpleSAML 测试身份验证源页面时,我有以下 cookie 值...
Name Value
SimpleSAMLAuthToken _a53569c0701dd02832532df14cf10cd0b2d9fcd6b6
biz.stage.originsystems.co.za 10fc356e0bfbf707af5fa5854c378755
ccof RGN002
xbrF 84aadc624fc51c0c9340d45645c08643
除了 SimpleSAMLAuthToken 之外的所有内容都来自我们的应用程序,不应影响 SimpleSAML。一旦我被重定向到 SSO Circle 并通过身份验证,我就会返回到 SimpleSAML 页面,并且 Auth Token 现在的值为 _39679e07cb1911e08b2bff3580a9929faddd07e9b6,并且所有相关信息都正确返回。日志文件显示以下活动。
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Received SAML2 Response from 'http://idp.ssocircle.com'.
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] No certificate in message when validating against fingerprint.
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Found 1 certificates in SAML2_Assertion
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Has 1 candidate keys for validation.
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Validation with key #0 succeeded.
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Filter config for http://idp.ssocircle.com->https://biz.stage.originsystems.co.za/simplesaml/module.php/saml/sp/metadata.php/default-sp: array ( 0 => sspmod_core_Auth_Process_LanguageAdaptor::__set_state(array( 'langattr' => 'preferredLanguage', 'priority' => 90, )),)
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Deleting state: '_742b094314383407864f56bccc6afd7de3dcb3211e'
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Session: doLogin("default-sp")
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Session: Valid session found with 'default-sp'.
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Session: Valid session found with 'default-sp'.
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Template: Reading [/OriginSystems/application/Updraft/web/external/System/SSO/simplesaml/dictionaries/status]
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Template: Reading [/OriginSystems/application/Updraft/web/external/System/SSO/simplesaml/dictionaries/attributes]
Feb 02 12:58:22 simplesamlphp DEBUG [7c4534ae0a] Template: Reading [/OriginSystems/application/Updraft/web/external/System/SSO/simplesaml/modules/core/dictionaries/frontpage]
如果我转到 https://biz.stage.originsystems.co.za?ccof=RGN002,我会被重定向到 SSO Circle,然后在那里进行身份验证。此时我的授权令牌的值为_39679e07cb1911e08b2bff3580a9929faddd07e9b6。一旦我通过身份验证,我将被定向到 SimpleSAML 错误页面“状态信息丢失”,并且身份验证令牌仍然是 _39679e07cb1911e08b2bff3580a9929faddd07e9b6。
日志显示...
Feb 02 13:08:31 simplesamlphp DEBUG [8abc64dd04] Loading state: '_498e7d4d75bb7716e5e8cf905e0da5ef1c40cf1b3f'
Feb 02 13:08:31 simplesamlphp ERROR [8abc64dd04] SimpleSAML_Error_NoState: NOSTATE
Feb 02 13:08:31 simplesamlphp ERROR [8abc64dd04] Backtrace:
Feb 02 13:08:31 simplesamlphp ERROR [8abc64dd04] 2 /OriginSystems/application/Updraft/web/external/System/SSO/simplesaml/lib/SimpleSAML/Auth/State.php:225 (SimpleSAML_Auth_State::loadState)
Feb 02 13:08:31 simplesamlphp ERROR [8abc64dd04] 1 /OriginSystems/application/Updraft/web/external/System/SSO/simplesaml/modules/saml/www/sp/saml2-acs.php:63 (require)
Feb 02 13:08:31 simplesamlphp ERROR [8abc64dd04] 0 /OriginSystems/application/Updraft/web/external/System/SSO/simplesaml/www/module.php:134 (N/A)
Feb 02 13:08:31 simplesamlphp ERROR [8abc64dd04] Error report with id dfbb52b0 generated.
Feb 02 13:08:31 simplesamlphp DEBUG [8abc64dd04] Template: Reading [/OriginSystems/application/Updraft/web/external/System/SSO/simplesaml/dictionaries/errors]
Feb 02 13:08:31 simplesamlphp DEBUG [8abc64dd04] Template: Reading [/OriginSystems/application/Updraft/web/external/System/SSO/simplesaml/modules/core/dictionaries/no_state]
在我看来,Auth Token 应该是_498e7d4d75bb7716e5e8cf905e0da5ef1c40cf1b3f,但不是出于某种原因。由于 SimpleSAML 找不到该 Token 它永远不会删除旧的并创建一个新的。也许我错了。我完全愿意被纠正。我的问题是我不知道是什么原因造成的。我已将配置文件中的 cookie.name 设置为“biz.stage.originsystems.co.za”,这对于 SimpleSAML 控制面板似乎工作正常,但在实际应用程序中使用 SP 时它不起作用。有人可以在这里指出我正确的方向吗?我迷路了。
【问题讨论】:
-
您获得的生成的 ID/令牌在某种程度上造成了问题,可能产生此错误的前三个原因是,1. 更改域名,例如您在 example.com 上跳到 www.example .com 导致会话无状态错误,2. 从 HTTP 跳转到 HTTPS 或 HTTPS 到 HTTP,3. 会话未正确保存,更多请考虑查看here
-
多思想者:这是一个很好的回应。您应该将其发布为答案,这样您就可以获得赏金。如果它对您不起作用,Andrew,您介意发布您的 SP 和 IDP 配置的元数据吗?
-
如果不查看元数据,很难给出具体答案,但我想指出,Firefox 有一个名为 Saml Tracer (addons.mozilla.org/en-US/firefox/addon/saml-tracer) 的插件,我一直在使用它调试 SSO 问题。可能会帮助您在不依赖调试语句的情况下跟踪来回发送的值。
-
您好,我也遇到了同样的问题。你解决了吗?
-
您是否在多台工作机器上运行代码? (例如,反向代理平衡器后面有多个 PHP 工作机器。)如果是这样,请确保所有工作人员都能看到 SimpleSAML 用于在不同请求之间保存数据的共享数据后端。
标签: php saml simplesamlphp