Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在基于SimpleSAMLphp的IdP中,如何用属性替换NameId的值?_Php_Docker_Saml_Saml 2.0_Simplesamlphp - Fatal编程技术网

在基于SimpleSAMLphp的IdP中,如何用属性替换NameId的值?

在基于SimpleSAMLphp的IdP中,如何用属性替换NameId的值?,php,docker,saml,saml-2.0,simplesamlphp,Php,Docker,Saml,Saml 2.0,Simplesamlphp,我正在尝试设置SimpleSAMLphp IdP,以便将SAML响应发送到本地开发服务器(本例中是SP启动的流)。此IdP基于Docker图像(我相信是1.15版) 整个设置是为了模拟我拥有的类似环境,其中G套件IdP用于同一个本地开发人员SP—试图最终从我的本地开发人员环境中消除云依赖性,并用等效的SimpleSAMLphp环境替换它 我遇到的问题是,Google在其SAML响应中发送NameId,如下所示: <saml2:Subject> <saml2:NameI

我正在尝试设置SimpleSAMLphp IdP,以便将SAML响应发送到本地开发服务器(本例中是SP启动的流)。此IdP基于Docker图像(我相信是1.15版)

整个设置是为了模拟我拥有的类似环境,其中G套件IdP用于同一个本地开发人员SP—试图最终从我的本地开发人员环境中消除云依赖性,并用等效的SimpleSAMLphp环境替换它

我遇到的问题是,Google在其SAML响应中发送NameId,如下所示:

<saml2:Subject> 
    <saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">a.b@c.com</saml2:NameID> 
                  <saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"> 
                     <saml2:SubjectConfirmationData InResponseTo="ONELOGIN_88ebd953f02c07d01b19714cd70133827ff1228e" NotOnOrAfter="2018-05-07T20:21:25.433Z" .                         Recipient="https://ee0138c4.ngrok.io/saml/?acs" /> 
</saml2:SubjectConfirmation>
</saml2:Subject>
其中users.php包含:

<?php
$config = array(
    'admin' => array(
        'core:AdminPassword',
    ),
    'example-userpass' => array(
        'exampleauth:UserPass',
        'user1:user1pass' => array(
            'uid' => array('1'),
            'Groups' => array('group1','group2', 'group3'),
            'email' => 'user1@example.com',
        ),
        'user2:user2pass' => array(
            'uid' => array('2'),
            'Groups' => array('group2', 'group4', 'group5'),
            'email' => 'user2@example.com',
        ),
    ),
);

以下设置对我有效:

Docker启动脚本: Docker容器中的
/var/www/simplesamlphp/metadata/saml20 idp hosted.php
中的
saml20 idp hosted.php
关于如何实现这一目标的总体思路有些模糊
但是这些文档不是为胆小的人准备的,当然也欢迎关于为什么事情是这样的部分

SimpleSAMLphp在此上下文中是idp还是SP?saml请求XML是什么样子的?请求通常是指定首选
NameIDFormat
的位置。SimpleSAMLphp是一个IdP。请求不应该是相关的,因为最终(尽管尚未)我们计划用IdP启动的SSO替换它。我们现在使用SP发起的重定向只是为了测试。我不知道idp发起的流如何工作,但您是否发送Google和您的测试idp相同的saml请求?如果您试图弄清楚为什么两个IDP发送不同的响应,而您没有向这两个IDP发送相同的请求,或者您没有在这两个IDP(或两者都没有)上指定首选的nameid格式,那么这并不是无关紧要的。是的,请求是由相同的代码生成的,因此是相同的。实际上,我尝试在SP配置中指定NameIdFormat,但没有任何区别。SP是基于Python的。本例中的IdP是Docker上的PHP,在Google中是clould,无论它们在内部使用什么。例如,如果将
添加到SAML请求中,您会从响应中得到什么?
docker run --name=testsamlidp_idp \
-p 8080:8080 \
-p 8443:8443 \
-e SIMPLESAMLPHP_SP_ENTITY_ID=https://ee0138c4.ngrok.io/saml/metadata \
-e SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE=https://ee0138c4.ngrok.io/saml/?acs  \
-e SIMPLESAMLPHP_SP_SINGLE_LOGOUT_SERVICE=http://localhost/simplesaml/module.php/saml/sp/saml2-logout.php/test-sp \
-v $(pwd)/users.php:/var/www/simplesamlphp/config/authsources.php \
-v $(pwd)/_saml20-sp-remote.php:/var/www/simplesamlphp/config/saml20-sp-remote.php \
-d kristophjunge/test-saml-idp
<?php
$config = array(
    'admin' => array(
        'core:AdminPassword',
    ),
    'example-userpass' => array(
        'exampleauth:UserPass',
        'user1:user1pass' => array(
            'uid' => array('1'),
            'Groups' => array('group1','group2', 'group3'),
            'email' => 'user1@example.com',
        ),
        'user2:user2pass' => array(
            'uid' => array('2'),
            'Groups' => array('group2', 'group4', 'group5'),
            'email' => 'user2@example.com',
        ),
    ),
);
<?php
/**
 * SAML 2.0 remote SP metadata for SimpleSAMLphp.
 *
 * See: https://simplesamlphp.org/docs/stable/simplesamlphp-reference-sp-remote
 */
$metadata[getenv('SIMPLESAMLPHP_SP_ENTITY_ID')] = array(

    'AssertionConsumerService' => getenv('SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE'),
    'SingleLogoutService' => getenv('SIMPLESAMLPHP_SP_SINGLE_LOGOUT_SERVICE'),

    #'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:persistent',
      #'simplesaml.nameidattribute' => 'email',
      #'simplesaml.attributes' => FALSE,

    'authproc.idp' => array(
            /* Filter to create a NameID with the "unspecified" format. */
            3 => array(
                'class' => 'saml:AtrributeNameID',
                'attribute' => 'email',
                'Format' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
            ),
        ),
        /* Select the unspecified NameID format by default. */
        'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified',

);
docker run --name=testsamlidp_idp \
-p 8080:8080 \
-p 8443:8443 \
-e SIMPLESAMLPHP_SP_ENTITY_ID=https://ee0138c4.ngrok.io/saml/metadata \
-e SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE=https://ee0138c4.ngrok.io/saml/?acs  \
-e SIMPLESAMLPHP_SP_SINGLE_LOGOUT_SERVICE=http://localhost/simplesaml/module.php/saml/sp/saml2-logout.php/test-sp \
-v $(pwd)/users.php:/var/www/simplesamlphp/config/authsources.php \
-v $(pwd)/saml20-idp-hosted.php:/var/www/simplesamlphp/metadata/saml20-idp-hosted.php \
-d kristophjunge/test-saml-idp
<?php

$metadata['__DYNAMIC:1__'] = array(
    /*
     * The hostname of the server (VHOST) that will use this SAML entity.
     *
     * Can be '__DEFAULT__', to use this entry by default.
     */
    'host' => '__DEFAULT__',
    // X.509 key and certificate. Relative to the cert directory.
    'privatekey' => 'server.pem',
    'certificate' => 'server.crt',
    /*
     * Authentication source to use. Must be one that is configured in
     * 'config/authsources.php'.
     */
    'auth' => 'example-userpass',

  'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',


// refer to https://simplesamlphp.org/docs/stable/saml:nameid
'authproc' => array(
  3 => array(
          'class' => 'saml:AttributeNameID',
          'attribute' => 'email',
          'Format' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
      ),
  ),

);
<?php
$config = array(
    'admin' => array(
        'core:AdminPassword',
    ),
    'example-userpass' => array(
        'exampleauth:UserPass',
        'user1:user1pass' => array(
            'uid' => array('1'),
            'Groups' => array('group1','group2', 'group3'),
            'email' => 'user1@example.com',
        ),
        'user2:user2pass' => array(
            'uid' => array('2'),
            'Groups' => array('group2', 'group4', 'group5'),
            'email' => 'user2@example.com',
        ),
    ),
);