在IdP身份验证之后/ SP重定向之前将文本附加到用户的帐户

时间:2012-12-26 17:16:21

标签: php authentication single-sign-on saml saml-2.0

我需要在验证了IdP之后,在系统将其重定向到SP之前,将电子邮件域(@ domain.com)附加到用户的帐户。

我正在使用此页面寻求帮助,但无法断言我是否会逐字输入其他文本,或者引用从LDAP检索到的其他属性:http://simplesamlphp.org/docs/stable/simplesamlphp-authproc

1 个答案:

答案 0 :(得分:1)

您必须在metadata / saml20-idp-hosted.php

上应用过滤器

使用PHP filter

'authproc.idp' => array(
    60 => array(
        'class' => 'core:PHP',
        'code' => '
             if (!empty($attributes["uid"])) {
                  $mail = $attributes["uid"][0] . "@domain.com";
                  $attributes["mail"] = array($mail);
             } //Closing bracket was missing
        ',
    ),
 ),

此过滤器例如根据'uid'属性创建'mail'属性。 请注意,$ attributes的属性值始终是一个数组。