首页 > 解决方案 > 如何使用soap请求在serviceprovider中添加oauth/openID配置

问题描述

我想在 wso2 的服务提供者下添加 oauth/openID 连接配置。我将如何使用肥皂请求添加这些配置。请帮助我。

标签: soapuiwso2is

解决方案


  1. 注册 OAuth 应用数据(https://localhost:9443/services/OAuthAdminService?wsdl)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd" xmlns:xsd1="http://dto.oauth.identity.carbon.wso2.org/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <xsd:registerOAuthApplicationData>
         <!--Optional:-->
          <xsd:application>
            <!--Optional:-->
            <xsd1:OAuthVersion>OAuth-2.0</xsd1:OAuthVersion>
            <!--Optional:-->
            <xsd1:applicationAccessTokenExpiryTime>3600</xsd1:applicationAccessTokenExpiryTime>
            <!--Optional:-->
            <xsd1:applicationName>webapp</xsd1:applicationName>
            <!--Optional:-->
            <xsd1:callbackUrl>http://localhost:8080/webapp/oauth2client</xsd1:callbackUrl>
            <!--Optional:-->
            <xsd1:grantTypes>refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer implicit password client_credentials iwa:ntlm authorization_code</xsd1:grantTypes>
            <!--Optional:-->
            <xsd1:pkceMandatory>false</xsd1:pkceMandatory>
            <!--Optional:-->
            <xsd1:pkceSupportPlain>true</xsd1:pkceSupportPlain>
            <!--Optional:-->
            <xsd1:refreshTokenExpiryTime>84000</xsd1:refreshTokenExpiryTime>
            <!--Optional:-->
            <xsd1:userAccessTokenExpiryTime>3600</xsd1:userAccessTokenExpiryTime>
         </xsd:application>
      </xsd:registerOAuthApplicationData>
   </soapenv:Body>
</soapenv:Envelope>
  1. 按名称获取 OAuth 应用程序数据 (https://localhost:9443/services/OAuthAdminService?wsdl)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <xsd:getOAuthApplicationDataByAppName>
         <!--Optional:-->
         <xsd:appName>webapp</xsd:appName>
      </xsd:getOAuthApplicationDataByAppName>
   </soapenv:Body>
</soapenv:Envelope>

注意:oauthConsumerKeyoauthConsumerSecret从响应中

<ax2402:oauthConsumerKey>kCVqngLf6fs0lQeXZwxL16ArRrAa</ax2402:oauthConsumerKey>
        <ax2402:oauthConsumerSecret>jauiJEAICB7Klk5us6FMSWjeEJoa</ax2402:oauthConsumerSecret>
  1. 创建一个应用程序(服务提供者)(https://localhost:9443/services/IdentityApplicationManagementService?wsdl)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.axis2/xsd" xmlns:xsd1="http://model.common.application.identity.carbon.wso2.org/xsd" xmlns:xsd2="http://script.model.common.application.identity.carbon.wso2.org/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:createApplication>
         <xsd:serviceProvider>
            <xsd1:applicationName>sample</xsd1:applicationName>
         </xsd:serviceProvider>
      </xsd:createApplication>
   </soap:Body>
</soap:Envelope>
  1. 获取 Application 并记下 applicationID (https://localhost:9443/services/IdentityApplicationManagementService?wsdl)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.axis2/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:getApplication>
         <!--Optional:-->
         <xsd:applicationName>sample</xsd:applicationName>
      </xsd:getApplication>
   </soap:Body>
</soap:Envelope>

笔记 : <ax2171:applicationID>15</ax2171:applicationID>

  1. 更新inboundAuthenticationConfig步骤 3 中创建的应用程序 (https://localhost:9443/services/IdentityApplicationManagementService?wsdl) 使用:
  • 在步骤 4 中找到的 applicationID
  • 在步骤 2 中找到的 oauthConsumerKey 作为 inboundAuthKey
  • 在步骤 2 中找到 oauthConsumerSecret 作为 oauthConsumerSecret 属性值
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.axis2/xsd" xmlns:xsd1="http://model.common.application.identity.carbon.wso2.org/xsd" xmlns:xsd2="http://script.model.common.application.identity.carbon.wso2.org/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:updateApplication>
         <xsd:serviceProvider>
            <xsd1:applicationID>15</xsd1:applicationID>
            <xsd1:applicationName>sample</xsd1:applicationName>
             <xsd1:inboundAuthenticationConfig>
               <xsd1:inboundAuthenticationRequestConfigs>
                  <xsd1:inboundAuthKey>kCVqngLf6fs0lQeXZwxL16ArRrAa</xsd1:inboundAuthKey>
                  <xsd1:inboundAuthType>oauth2</xsd1:inboundAuthType>
                  <xsd1:properties>
                     <xsd1:name>oauthConsumerSecret</xsd1:name>
                     <xsd1:value>jauiJEAICB7Klk5us6FMSWjeEJoa</xsd1:value>
                  </xsd1:properties>
               </xsd1:inboundAuthenticationRequestConfigs>
            </xsd1:inboundAuthenticationConfig>
         </xsd:serviceProvider>
      </xsd:updateApplication>
   </soap:Body>
</soap:Envelope>

参考:https ://docs.wso2.com/display/IS570/Service+Provider+Configurations+used+with+APIs#ServiceProviderConfigurationsusedwithAPIs-ConfiguringOAuth/OpenIDConnect


推荐阅读