文档首页> 合作伙伴中心> API参考> 附录> 跳转到华为云页面绑定华为云账号
更新时间:2023-10-23 GMT+08:00

跳转到华为云页面绑定华为云账号

介绍合作伙伴客户如何通过Web UI方式将合作伙伴销售平台上客户的账号与华为云账号绑定。包括如下场景:

  • 客户在伙伴销售平台已创建了账号,在华为云没有账号,需创建华为云账号并与伙伴销售平台账号绑定。
  • 客户在伙伴销售平台创建账号前,已经在华为云创建了账号,需创建伙伴销售平台账号并与已有的华为云账号绑定。

后续订购产品、查询订单等场景依赖于该场景中客户的华为云账号。

客户在合作伙伴销售平台开通华为云账号并通知绑定结果的流程如图1所示。

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

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

      参数

      是否必填

      说明

      示例

      xAccountType

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

      ZXT

      isFirstLogin

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

      true

      service

      登录后的跳转地址。

      需要使用encodeURIComponent编码。

      https%3a%2f%2fconsole-intl.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返回体response.xml。
      此返回体为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

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

      bpId

      合作伙伴ID。

      获取方法请参见如何获取合作伙伴ID(partner_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

      合作伙伴客户的华为云账号名。

      内容非必填。

      校验规则:

      • 长度限制: 5~32
      • 只能包含字母、数字或者-_字符,不能以数字开头。中间可以包含空格。
      • 使用正则表达式校验:"^([a-zA-Z\\_\\- ][0-9a-zA-Z\\_\\- ]*)+$"

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

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

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

      参数

      描述

      SAMLResponse

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

      RelayState

      samlRequest中相同参数值。

  3. 创建华为云账号并与合作伙伴销售平台的账号进行绑定。

    SAMLResponse返回成功,IAM会根据返回信息,判断华为云是否存在与此合作伙伴销售平台的客户账号相关联的华为云账号,如果存在直接登录,如果不存在会自动跳转到账号创建及绑定页面。

    • 创建华为云账号页面如图2所示,合作伙伴客户根据界面提示填写相关信息,单击“创建并绑定”即可完成客户的华为云账号创建以及合作伙伴销售平台的账号与华为云账号的绑定。
      图2 华为云账号创建页面
    • 如果合作伙伴客户已有华为云账号,可以单击图3的“绑定账号”,根据界面提示填写相关信息,单击“绑定账号”即可完成客户在合作伙伴销售平台的账号与华为云账号的绑定。
      如果客户的已有华为云账号存在以下情况,则无法与客户在合作伙伴销售平台的账号进行绑定:
      • 有欠费;
      • 已经关联其他合作伙伴;
      • 已与华为云签署指定合同(线下直签合同、电销授权合同折扣、直签特价商务)等;
      • 已经是咨询类合作伙伴账号或者申请中的咨询类合作伙伴账号;
      • 已经是企业子账号或者关联有企业子账号的企业主账号;
      • 账户有消费或有资源开通;
      • 存在未失效预留实例。
      图3 已有华为云账号绑定页面
  4. 华为云根据合作伙伴提供的绑定通知接口通过浏览器重定向的方式通知合作伙伴账号绑定结果,合作伙伴销售平台进行请求签名验证。
    1. 获取请求参数bindRequest、 SigAlg、 Signature。
    2. 将Signature进行BASE64解码后,使用签名算法SigAlg对bindRequest参数值进行签名验证。

      签名验证,华为云使用SAML对接的私钥签名, 合作伙伴使用华为云的SAML对接的公钥(SP Metadata.xml文件中<ds:X509Certificate></ds:X509Certificate>标签内的值)进行验证签名。

    3. 签名验证通过,对bindRequest进行BASE64解码得到JSON字符串,后续根据JSON数据进行相应的业务处理。签名验证不通过,则请求非法,终止处理。