无法理解SimpleSAMLphp的{Return}重定向

时间:2016-06-10 21:01:09

标签: php simplesamlphp

尝试在simplesamlphp中设置重定向,以便在发送到身份验证之前将用户带回他们尝试访问的页面。

我使用ReturnTo选项:

$as->requireAuth(array("ReturnTo" => $returnURL, 'KeepPost' => FALSE));

使用remote-idp的元数据设置如下(例如剥离):

$metadata['sample'] = array(
  'name' => 'sample',
  'entityid' => 'https://sample.com/saml/module.php/saml/sp/metadata.php/sample',
  'metadata-set' => 'saml20-idp-remote',
  'SingleSignOnService' => 
      array (
        0 => 
            array (
              'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
              'Location' => 'https://sample:port/idp/startSSO.ping?PartnerSpId=https://sample.com/saml/module.php/saml/sp/metadata.php/sample'
            )
      ),
  'keys' => array(...)
);

我需要传递一个参数" TARGET"在上面的元数据中进入idp startSSO,但是还没有找到如何翻译" ReturnTo"要添加到此SSO URL的选项。我还捕获/检查了SAML重定向xml,而ReturnTo根本就没有。有谁知道怎么做?

1 个答案:

答案 0 :(得分:1)

  

尝试在simplesamlphp中设置重定向以将用户带回   他们在被发送之前尝试访问的页面   认证

使用不带任何选项的ReturnTo方法默认重定向到用户尝试访问的页面。

From documentation

  

ReturnTo(string)
  用户应该返回的URL   认证。默认设置是将用户返回到当前页面。

只需将此代码包含在需要身份验证的页面中。

require_once 'path/to/simplesamlphp/lib/_autoload.php';

$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();
相关问题