【问题标题】:How do I map attributes returned by an IDP to friendly names inSimpleSAMLphp?如何将 IDP 返回的属性映射到 SimpleSAMLphp 中的友好名称?
【发布时间】:2016-05-15 10:18:57
【问题描述】:

我已成功配置 simpleSAMLphp,以便它通过测试 Shib IDP (https://www.testshib.org/) 进行身份验证。

Test Shib 返回以下属性:

  • urn:oid:0.9.2342.19200300.100.1.1
  • urn:oid:1.3.6.1.4.1.5923.1.1.1.1
  • urn:oid:1.3.6.1.4.1.5923.1.1.1.6
  • urn:oid:2.5.4.4
  • urn:oid:1.3.6.1.4.1.5923.1.1.1.9
  • urn:oid:2.5.4.42
  • urn:oid:1.3.6.1.4.1.5923.1.1.1.7
  • urn:oid:2.5.4.3
  • urn:oid:1.3.6.1.4.1.5923.1.1.1.10
  • urn:oid:2.5.4.20

我想将这些属性映射到友好名称。谁能给我一些关于如何做到这一点的指示?

authsources.php 中的 default-sp 示例如下:

/*
 * The attributes parameter must contain an array of desired attributes by the SP.
 * The attributes can be expressed as an array of names or as an associative array
 * in the form of 'friendlyName' => 'name'.
 * The metadata will then be created as follows:
 * <md:RequestedAttribute FriendlyName="friendlyName" Name="name" />
 */
 /*'attributes' => array(
   'attrname' => 'urn:oid:x.x.x.x',
 ),*/

但是设置

'attributes' => array('myTestValue' => 'urn:oid:0.9.2342.19200300.100.1.1'),

没有效果。

我们将非常感激任何帮助!

【问题讨论】:

    标签: php saml-2.0 simplesamlphp


    【解决方案1】:

    假设SimpleSAMLPHP 1.6 及更高版本,您可以简单地使用oid2name 中的内置属性映射来为您进行映射。

    'authproc' => array( 50 => array( 'class' => 'core:AttributeMap', 'oid2name', ), ),

    要添加到 Luke 的答案,您可以简单地在以下位置添加一个 authproc 过滤器:

    • 全局在 config.php 中
    • 在 SP 上:仅针对 authsources.php 中的 SP
    • 在 SP 上:仅针对 saml20-idp-remote 或 shib13-idp-remote 中的一个远程 IdP
    • 在 IdP 上:仅针对 saml20-idp-hosted 或 shib13-idp-hosted 中的一个托管 IdP
    • 在 IdP 上:仅特定于 saml20-sp-remote 或 shib13-sp-remote 中的一个远程 SP

    取自https://simplesamlphp.org/docs/stable/simplesamlphp-authproc


    您可以在此处找到的源代码中查看其他 AttributeMap,例如 oid2urnoid2feide

    https://github.com/simplesamlphp/simplesamlphp/tree/master/attributemap

    【讨论】:

    • 注意,不确定它是否改变了,但看起来关键是全局配置中的 authproc.sp(或 .idp),根据该文档上的“1.1 config.php 中的过滤器”部分页。以防万一其他人在这不起作用时感到困惑。
    【解决方案2】:

    根据https://simplesamlphp.org/docs/stable/simplesamlphp-authproc,操作属性的正确方法是通过“authproc”功能。

    就我而言,我在 config/saml20-idp-remote.php 中为 https://idp.testshib.org/idp/shibboleth 添加了以下配置数组:

    'authproc' => array(
        50 => array(
            'class' => 'core:AttributeCopy',
            'urn:oid:0.9.2342.19200300.100.1.1' => 'uid',
        ),
    ),
    

    文档建议可以在以下位置添加此配置数组:

    • 全局在 config.php 中
    • 在 SP 上:仅针对 authsources.php 中的 SP
    • 在 SP 上:仅针对 saml20-idp-remote 或 shib13-idp-remote 中的一个远程 IdP
    • 在 IdP 上:仅针对 saml20-idp-hosted 或 shib13-idp-hosted 中的一个托管 IdP
    • 在 IdP 上:仅特定于 saml20-sp-remote 或 shib13-sp-remote 中的一个远程 SP

    请注意,您可能需要清除所有会话(关闭并重新打开浏览器)才能使更改生效。

    供将来参考的重要提示 - 始终阅读最新版本的文档!

    【讨论】:

    猜你喜欢
    • 2020-07-28
    • 2020-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多