编程语言
首页 > 编程语言> > 如何将IDP返回的属性映射到SimpleSAMLphp中的友好名称?

如何将IDP返回的属性映射到SimpleSAMLphp中的友好名称?

作者:互联网

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

Test Shib返回以下属性:

enter image description here

> 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'),

没有效果.

非常感谢任何帮助!

解决方法:

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

‘authproc’=>阵列(
    50 =>阵列(
        ‘class’=> ‘核心:AttributeMap’,
        ‘oid2name’,
    )
)

要添加到Luke的答案,您只需在以下位置添加authproc过滤器:

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

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

您可以在此处找到的源中看到其他AttributeMaps,例如oid2urn和oid2feide:

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

标签:saml-2-0,php,simplesamlphp
来源: https://codeday.me/bug/20190829/1760380.html