【发布时间】:2014-03-27 15:29:58
【问题描述】:
我设置了两个 simplesamlphp 服务器,它们都在同一个物理服务器上,但由虚拟主机隔开。他们目前在域中。
id.saml.domain.com
sp.saml.domain.com
我还有第三个站点,即我实际上打算实现单点登录的 Web 应用程序。我们称之为
test.domain.com/webapplication
我让服务提供者和身份提供者使用 example-auth 相互交谈。我可以去服务提供商,点击“测试身份验证源”,发送到身份服务器,然后获得登录提示,输入示例凭据,点击提交,然后发送回服务提供商。
此时,一切看起来都很好。
我的问题是,当我尝试在网站中实现服务提供者时。
我有以下登录代码来调用服务提供商代码
$lib = "/ltsites/saml/service/lib";
$sp = "default-sp"; // Name of SP defined in config/authsources.php
try {
// Autoload simplesamlphp classes.
if(!file_exists("{$lib}/_autoload.php")) {
throw(new Exception("simpleSAMLphp lib loader file does not exist: ".
"{$lib}/_autoload.php"));
}
include_once("{$lib}/_autoload.php");
$as = new SimpleSAML_Auth_Simple($sp);
// Take the user to IdP and authenticate.
$as->requireAuth();
$valid_saml_session = $as->isAuthenticated();
} catch (Exception $e) {
// SimpleSAMLphp is not configured correctly.
throw(new Exception("SSO authentication failed: ". $e->getMessage()));
return;
}
if (!$valid_saml_session) {
// Not valid session. Redirect a user to Identity Provider
try {
$as = new SimpleSAML_Auth_Simple($sp);
$as->requireAuth();
} catch (Exception $e) {
// SimpleSAMLphp is not configured correctly.
throw(new Exception("SSO authentication failed: ". $e->getMessage()));
return;
}
}
// At this point, the user is authenticated by the Identity Provider, and has access
// to the attributes received with SAML assertion.
$attributes = $as->getAttributes();
它确实将我一直转发到身份服务器并要求提供凭据。但是在返回服务提供商时,我得到了错误
State information lost
SimpleSAML_Error_NoState: NOSTATE
我找到了这个 wiki 页面 https://code.google.com/p/simplesamlphp/wiki/LostState,但在阅读后我没有做任何事情(比如更改 config\config.php 中的 'session.cookie.domain',这只是将页面发送到无限刷新循环)
有人有什么想法吗?我设置不正确吗?我在想也许网络应用程序本身必须是服务提供者?即test.domain.com/webapplication/simplesaml/,以便两者在同一个域上?
【问题讨论】:
标签: php simplesamlphp