我设置了两个simplesamlphp服务器,它们都在同一台物理服务器上,但由虚拟主机分隔。他们目前在这些领域。
id.saml.domain.com
< - 身份提供者
sp.saml.domain.com
< - 服务提供商
我还有第三个网站,我实际打算实施单点登录的网络应用程序。我们称之为
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'
中的config\config.php
,它只是将页面发送到无限刷新循环中)< / p>
有没有人有任何想法?我错误地设置了吗?我想也许Web应用程序本身必须是服务提供商?即test.domain.com/webapplication/simplesaml/
以便两者在同一个域上?
答案 0 :(得分:1)
您可以尝试在config.php中更改会话store.type。您可以在服务提供商或身份提供商中执行此操作。某种方式,两者有不同的会话存储。适合我。