我设置了两个 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,但我在阅读后没有做任何事情(比如更改'session.cookie.domain'
in config\config.php
,它只是将页面发送到无限刷新循环)工作
有人有什么想法吗?我设置不正确吗?我在想也许网络应用程序本身必须是服务提供者?即test.domain.com/webapplication/simplesaml/
,使两者在同一个域上?