【问题标题】:simpleSamlPHP isAuthenticated always returning falsesimpleSamlPHP isAuthenticated 总是返回 false
【发布时间】:2021-01-24 01:30:53
【问题描述】:

我刚开始使用 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。我还需要做其他事情吗?还是我错过了什么?

【问题讨论】:

  • 假设您已经正确配置了所有内容(身份提供程序等),这几乎就是您完成应用程序所需的全部内容。在 SimpleSAML 中配置调试日志并查看您尝试进行身份验证时发生的情况。

标签: php single-sign-on saml simplesamlphp


【解决方案1】:

在拨打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";
}

【讨论】:

    猜你喜欢
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    • 2014-04-28
    • 2019-01-05
    • 1970-01-01
    • 1970-01-01
    • 2016-07-20
    • 2021-11-05
    相关资源
    最近更新 更多