我刚刚开始使用simplesamlPHP进行开发。我安装了simpleSamlPhp,并按照https://simplesamlphp.org/docs/development/simplesamlphp-sp-api中给出的步骤将我的php应用程序与simpleSAMLPhp集成在一起,我正在使用文档中给出的simpleSaml API。
代码如下:
require_once('/var/simplesamlphp/lib/_autoload.php');
$auth = new \SimpleSAML\Auth\Simple('default-sp');
if($auth->isAuthenticated()){
$attributes = $auth->getAttributes();
}else{
echo "Not authenticated";
$auth->requireAuth();
}$auth->isAuthenticated()总是返回false。我还需要做什么吗?还是我错过了什么?
发布于 2021-08-18 13:30:44
在调用isAuthenticated()之前,需要先调用requireAuth()。其思想是您请求对一个实体进行身份验证,然后您可以检查该用户是否经过了身份验证。
require_once('/var/simplesamlphp/lib/_autoload.php');
$auth = new \SimpleSAML\Auth\Simple('default-sp');
$auth->requireAuth();
if($auth->isAuthenticated()){
$attributes = $auth->getAttributes();
}else{
echo "Not authenticated";
}https://stackoverflow.com/questions/64272048
复制相似问题