更新时间:2023-11-09 GMT+08:00
分享

Web UI方式

客户在伙伴销售平台登录后,可以直接跳转到华为云完成云服务购买、云服务资源管理等。伙伴销售平台需完成SAML认证,与华为云建立信任关系。

前提条件

合作伙伴已完成接入配置

SAML认证

合作伙伴销售平台与华为云进行SAML认证的流程如图1所示。

图1 SAML认证流程

  1. 合作伙伴客户通过浏览器调用华为云登录链接,IAM发起samlRequest请求。
    1. 合作伙伴客户通过浏览器调用华为云登录链接。

      https://auth.huaweicloud.com/authui/saml/login?xAccountType=ZXT&isFirstLogin=false&service=https%3a%2f%2fconsole.huaweicloud.com%2fiam%2f

      参数

      是否必填

      说明

      示例

      xAccountType

      合作伙伴销售平台标识,全局唯一。该标识的具体值由华为分配。合作伙伴在合作伙伴中心完成接入配置后,即可生成该标识。获取方法请参见如何获取xaccountType的取值

      ZXT

      isFirstLogin

      未绑定华为云账号,此参数必填且为true,其他可不填或为false。

      成功调用“创建客户”接口后,华为云CBC已经将合作伙伴客户的合作伙伴销售平台账号和华为云账号进行了绑定。

      false

      service

      登录后的跳转地址。

      需要使用encodeURIComponent编码。

      https%3a%2f%2fconsole.huaweicloud.com%2fiam%2f

    2. IAM服务收到合作伙伴客户的登录请求,根据xAccountType的取值,查找对应IDP Metadata.xml配置,找出SingleSignOnService配置项,向此路径发送samlRequest请求。

      参数

      描述

      SAMLRequest

      返回消息体。

      此消息为应答xml,IAM对此请求进行了“压缩 > base64加密 > url编码”。

      • 如果合作伙伴使用SAML库,可直接使用此参数值,不必完全解出xml。
      • 如果合作伙伴想解出xml,需要进行“解url > 解base64 > 解压缩(zip.inflate)”,可参考解出SAMLRequest的代码示例

      RelayState

      SAML协议返回参数。

      SigAlg

      签名使用的签名算法(华为默认使用SHA256算法进行签名)。

      HTTP://WWW.W3.ORG/2001/04/XMLDSIG-MORE#RSA-SHA256

      Signature

      签名值。通过签名机制来验证请求的发起方。

      华为云发起请求时将请求https://www.test.com/saml/login?SAMLRequest={SAMLRequest }&RelayState={ RelayState} &SigAlg={ SigAlg}&Signature={ Signature }

      中的“SAMLRequest={ SAMLRequest }&RelayState={ RelayState } &SigAlg={ SigAlg }”使用私钥签名(签名算法为SigAlg字段指定的算法),之后再做一次Base64编码作为签名值。

      接收方收到请求后通过华为云提供的公钥(SP Metadata.xml文件中<ds:X509Certificate></ds:X509Certificate>标签内的值)来验证签名。

      签名验证通过,则表明是华为云发送的请求可以进行后续操作,否则请求非法。

  2. 合作伙伴销售平台生成samlResponse,并返回给华为云IAM。
    1. 合作伙伴销售平台读取SP Metadata.xml文件获取华为云公钥及samlResponse返回路径。具体请参见获取SP Metadata.xml中“示例及公钥、应答路径说明”的说明。
    2. 合作伙伴销售平台构建samlResponse返回体。
      此返回体为xml格式,正确返回体及参数说明请参见如下屏显内容。

      如下屏显内容仅作为校验比对。除注释中描述的信息必须修改外,SAML自身定义的时间和ID也是变化的,因此不建议直接修改此response内容,应由SAML相关类库生成。

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- InResponseTo需要与samlRequest请求的AuthnRequest中的ID配置项保持一致 -->
      <!-- Destination需要与SPMetadata中AssertionConsumerService标签下的Location的值保持一致 -->
      <saml2p:Response Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" ID="_d794dc393ae6724e236003bf0b917cf0" Destination="https://auth.huaweicloud.com/authui/saml/SAMLAssertionConsumer"
      InResponseTo="_dck4mm08qmdhc8k4nuir07hghetdqqg8umg5" IssueInstant="2018-10-30T08:21:41.740Z" Version="2.0"
          xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol">
        <!-- 必须与IDP Metadata.xml中的entityID保持一致 -->
        <saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity" 
          xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">https://www.test.com</saml2:Issuer>
        <saml2p:Status>
          <saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
          <saml2p:StatusMessage>urn:oasis:names:tc:SAML:2.0:status:Success</saml2p:StatusMessage>
        </saml2p:Status>
        <saml2:Assertion ID="_2320c40ac7b5e857b2d0d4ea0c8758c3" IssueInstant="2018-10-30T08:21:41.740Z" Version="2.0" 
          xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" 
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <!-- 必须与IDP Metadata.xml的entityID保持一致 -->
          <saml2:Issuer>https://www.test.com</saml2:Issuer>
          <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
            <ds:SignedInfo>
              <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
              <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
              <!-- URI #号后面的值必须和Assertion标签中的ID保持一致 -->
              <ds:Reference URI="#_2320c40ac7b5e857b2d0d4ea0c8758c3">
                <ds:Transforms>
                  <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                  <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                    <ec:InclusiveNamespaces PrefixList="xsd" 
                      xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" />
                  </ds:Transform>
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                <!-- DigestValue的值为Assertion标签对象做的摘要,摘要算法和DigestMethod一致 -->
                <ds:DigestValue>rFxrycznfGNYOnprZIFJJou4ro0Mz65+43MIR5F0+H4=</ds:DigestValue>
              </ds:Reference>
            </ds:SignedInfo>
            <!-- 合作伙伴签名值,具体生成方法请参见下文描述 -->
            <ds:SignatureValue>
              YqTWQngAPfGqQmWa610PM7LeefqWdKuveUVINrqL67NoHJIDa2WxLwdVzoJIlJh64QiNPr6+ndmL DCMgIC5F/9ijuzhIICZcc6lHNIjy6EsPkKRjfo9oeoVAqLgG/kmVQYeHLBID0y11RNXXpAVY4nhJ 26KiIVGt7ywyKAmhichE+eW/UYAGiOI5vkfgD2gZUGV+yPkv64k7xK4yAH3mL2NaCPuw/90e4enm iUx0YuazDwM5FiRUSMpcJs0rcNmS6clWAUcCzbOx+y2vJGtTjHb7k3UsmpnTop5eYNp94+sDPEat 8FaV4SgafMEL5z54gpe8+//9yOWEvlBs1b0RYg==
            </ds:SignatureValue>
            <ds:KeyInfo>
              <ds:X509Data>
              <!-- 合作伙伴公钥证书,必须与IDP Metadata.xml的公钥证书保持一致 -->
                <ds:X509Certificate>
      MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhK3L160NjP9EhBGQOC2s4r+Wc62bkRkc nUxfhiZwCwJdQCykzuLOAoATnfoEamV5W25xtSS5kFs+4OC0mYVpKcI3SWoydX+UE5Qik5UfJ8Dt G1AvSEKhSluyO9axrV5Uv089jMxBnlm/R+xND73WcZM11yIbKJEZSTCEDfh+KnFbMw108umFMden RZCrNWUJoSp/90XeG0V2Nmj7Fkq72skSifwIASLRq9KqLbmh1QwUX+AoWpHK/jRUBustMBmG1n1i
                  AqpD4EBjjBOB27k1wXZ30+IoJt8IZmfSZRFoNn5VFWXNeEmZ1aQvGSvd3Tyyw2/Wr+w/8Mags69C mpeX6QIDAQAB
                </ds:X509Certificate>
              </ds:X509Data>
            </ds:KeyInfo>
          </ds:Signature>
          <saml2:Subject>
          <!-- NameQualifier取值必须与SP Metadata.xml的entityID保持一致 -->
            <saml2:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient" NameQualifier="https://auth.huaweicloud.com/">Some NameID value</saml2:NameID>
            <saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
              <!-- InResponseTo需要与samlRequest请求的AuthnRequest中的ID配置项保持一致 -->
              <saml2:SubjectConfirmationData InResponseTo="_dck4mm08qmdhc8k4nuir07hghetdqqg8umg5" NotBefore="2018-10-28T08:21:41.740Z" NotOnOrAfter="2018-11-01T08:21:41.740Z" Recipient="https://auth.huaweicloud.com/authui/saml/SAMLAssertionConsumer" />
            </saml2:SubjectConfirmation>
          </saml2:Subject>
          <saml2:Conditions NotBefore="2018-10-28T08:21:41.740Z" NotOnOrAfter="2018-11-01T08:21:41.740Z">
            <saml2:AudienceRestriction>
            <!-- 必须与SP Metadata.xml的entityID保持一致  -->
              <saml2:Audience>https://auth.huaweicloud.com/</saml2:Audience>
            </saml2:AudienceRestriction>
          </saml2:Conditions>
          <saml2:AttributeStatement>
            <!-- <saml2:AttributeValue></saml2:AttributeValue>之间的取值请参见下表的说明  -->
            <saml2:Attribute FriendlyName="xUserId" Name="xUserId" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
              <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">*******</saml2:AttributeValue>
            </saml2:Attribute>
            <!-- xAccountId和xUserId属性的值须一致  --> 
            <saml2:Attribute FriendlyName="xAccountId" Name="xAccountId" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
              <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">********</saml2:AttributeValue>
            </saml2:Attribute>
            <saml2:Attribute FriendlyName="bpId" Name="bpId" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
              <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">******</saml2:AttributeValue>
            </saml2:Attribute>
            <saml2:Attribute FriendlyName="email" Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
              <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string" />
            </saml2:Attribute>
            <saml2:Attribute FriendlyName="name" Name="name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
              <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">******</saml2:AttributeValue>
            </saml2:Attribute>
            <saml2:Attribute FriendlyName="mobile" Name="mobile" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
              <saml2:AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">*****</saml2:AttributeValue>
             </saml2:Attribute>
          </saml2:AttributeStatement>
          <saml2:AuthnStatement AuthnInstant="2018-10-30T08:21:41.741Z">
            <!-- 必须与SP Metadata.xml的entityID保持一致 -->
            <saml2:SubjectLocality Address="https://auth.huaweicloud.com/" />
            <saml2:AuthnContext>
              <saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml2:AuthnContextClassRef>
            </saml2:AuthnContext>
          </saml2:AuthnStatement>
        </saml2:Assertion>
      </saml2p:Response>

      合作伙伴签名值使用标准的XML签名方式,签名类型为enveloped-signature。建议优先使用第三方提供的SAML库进行签名。

      签名步骤如下:

      1. 获取签名对象(Assertion)
        <saml2:Assertion ID="_2320c40ac7b5e857b2d0d4ea0c8758c3" IssueInstant="2018-10-30T08:21:41.740Z" Version="2.0"
            xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
        ...... 
        
        </saml2:Assertion>
      2. 获取标签对象(Signature)
        <ds:Signature
            xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
            <ds:SignedInfo>
                <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha256" />
                <ds:Reference URI="#_2320c40ac7b5e857b2d0d4ea0c8758c3">
                    <ds:Transforms>
                        <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                            <ec:InclusiveNamespaces
                                xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"
                                              PrefixList="xs" />
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
                        <ds:DigestValue>......</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <!-- 第三方签名值 -->
                <ds:SignatureValue> 
                ...... 
              </ds:SignatureValue>
                <ds:KeyInfo>
                    <ds:X509Data>
                        <!-- 第三方公钥证书 -->
                        <ds:X509Certificate> 
                    ...... 
                  </ds:X509Certificate>
                    </ds:X509Data>
                </ds:KeyInfo>
            </ds:Signature>
      3. 对签名对象Assertion生成“DigestValue”摘要值
        1. 对Assertion按照Signature的Transform子标签中的算法进行标准化转换;
        2. 1)转换后的对象按照DigestMethod中的算法生成摘要;
        3. 将生成的摘要值放在DigestValue标签中。
      4. 使用生成证书步骤6的私钥对SignedInfo对象签名生成“SignatureValue”值
        1. 对SignedInfo按照 CanonicalizationMethod 中的算法进行标准化转换;
        2. 1)转换后的对象按照SignatureMethod中的签名算法进行签名,签名值放在SignatureValue中。
      5. 将 “DigestValue”和“SignatureValue”值组成最终的Signature对象,将Signature放置于Assertion对象中,作为其子元素。

      签名后的屏显如下:

      <saml2:Assertion ID="_2320c40ac7b5e857b2d0d4ea0c8758c3" IssueInstant="2018-10-30T08:21:41.740Z" Version="2.0"
          xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
          ...... 
          <ds:Signature
              xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> 
              ...... 
              <!-- 第三方签名值 -->
              <ds:SignatureValue> 
              ...... 
            </ds:SignatureValue>
              <ds:KeyInfo>
                  <ds:X509Data>
                      <!-- 第三方公钥证书 -->
                      <ds:X509Certificate> 
                  ...... 
                </ds:X509Certificate>
                  </ds:X509Data>
              </ds:KeyInfo>
          </ds:Signature>
      </saml2:Assertion>
      表1 <saml2:AttributeValue></saml2:AttributeValue>之间的取值说明

      参数

      描述

      xUserId

      合作伙伴客户在合作伙伴销售平台的用户ID,即xAccountId的取值。

      xAccountId

      合作伙伴客户在合作伙伴销售平台的账号ID。

      bpId

      如果客户需要关联至解决方案提供商或华为云总经销商(一级经销商),则此处需填写解决方案提供商或华为云总经销商的伙伴ID,获取方法请参见如何获取合作伙伴ID(partner_id)

      如果客户需要关联至云经销商(二级经销商),则此处需填写云经销商的伙伴ID,获取方法请参见查询云经销商列表

      email

      邮箱内容。

      内容非必填。

      校验规则:

      • 客户间判重。
      • 最大长度:64
      • 使用正则表达式校验:"^[azA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[azA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"

      name

      合作伙伴销售平台传递的客户名称。

      内容非必填。

      请与“创建客户”接口请求参数中的“domain_name”取值保持一致。

      mobile

      手机号码,格式为“国家码-手机号码”。

      内容非必填。

      手机号码请与“创建客户”接口请求参数中的“mobile_phone”保持一致。

      表1中有账号ID和用户ID的定义是因为华为云IAM有账号和用户的概念。关于两个概念的具体介绍请参见身份管理中“账号”和“IAM用户”的描述。

    3. 如果客户已在合作伙伴销售平台登录,则直接返回samlResponse消息。如果未登录,则登录后返回samlResponse消息。

      2.a中华为云应答路径AssertionConsumerService发送POST请求,参数使用Form Data形式。

      参数

      描述

      SAMLResponse

      2.b中samlResponse返回体经过base64加密后的字符串。

      RelayState

      samlRequest中相同参数值。

  3. IAM解析SAMLResponse。由于在调用“创建客户”接口时,华为云CBC将客户在合作伙伴销售平台上的账号与华为云账号进行了绑定,所以此时可直接登录到service重定向的页面,完成云服务的购买和管理。
分享:

    相关文档

    相关产品