如何在微积分器中使用WSO2 OAuth介体4.1

发布于 2025-01-24 03:31:34 字数 2246 浏览 3 评论 0原文

我无法弄清楚如何使用WSO2 OAuth调解器。我使用WSO2 Micro Integrator 4.1,Identity Server 5.11和WSO2 IntegrationStudio 8.1。

  1. 这是真的:OAuth Mediator获取访问令牌并将其发送到身份服务器并在访问令牌有效的情况下获得答案吗?

  2. 我们应该在序列开始时添加一个OAuth调解人?

  3. OAuth调解人应发生什么?

  4. 使用OAuth调解器时的卷曲消息是什么样的?

我有这样的API(没有OAuth调解器):

<api context="/user-service3" name="Soap2Rest" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
    <inSequence>
        <send>
            <endpoint>
                <http method="post" uri-template="http://localhost:9090/user-service" />
            </endpoint>
        </send>
    </inSequence>
    <outSequence>
        <send/>
    </outSequence>
    <faultSequence>
        <send/>
    </faultSequence>
</resource>

我发送这样的卷曲消息:

curl -X 'POST' -k 'https://localhost:8253/user-service3' \
-H 'Content-Type: application/soap+xml' \
-H 'accept: */*' \
-d '
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:user="http://user.ws.xx.com/">
   <soap:Header/>
   <soap:Body>
      <user:createUser>
         <arg0>abc</arg0>
       </user:createUser>
    </soap:Body>
 </soap:Envelope>'

在不序列开始时添加OAuth Mediator后,我应该在curl命令中更改curl命令?

<oauthService remoteServiceUrl="https://testdomain.org:9444/services/" username="admin" password="admin"/> -->

我尝试了不同的方式,但是从WSO2身份服务器中获取错误。 我将授权标头添加到卷发中。

-H 'Authorization : Bearer 8aa447a9-b929-355c-a885-1b92c5266051' \

但是微积分显示了此日志:

INFO {LogMediator} - Direction: request, MESSAGE = Executing default 'fault' sequence, 
ERROR_CODE = 0, ERROR_MESSAGE = Error occured while validating oauth 2.0 access token, 
Envelope: 
<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:user="http://user.ws.xx.com/">
<soap:Body>
  <user:createUser>
     <arg0>abc</arg0>
  </user:createUser>
 </soap:Body></soap:Envelope>

I can not figure out how to use the wso2 OAuth mediator. I use the wso2 micro integrator 4.1, identity server 5.11, and wso2 IntegrationStudio 8.1.

  1. Is this true: OAuth mediator gets an access token and sends it to the identity server and gets the answer if the access token is valid or not?

  2. We should add an OAuth mediator at the beginning of an inSequence?

  3. What should come after the OAuth mediator?

  4. What does the curl message look like when using the OAuth mediator?

I have an API like this (without an OAuth mediator):

<api context="/user-service3" name="Soap2Rest" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
    <inSequence>
        <send>
            <endpoint>
                <http method="post" uri-template="http://localhost:9090/user-service" />
            </endpoint>
        </send>
    </inSequence>
    <outSequence>
        <send/>
    </outSequence>
    <faultSequence>
        <send/>
    </faultSequence>
</resource>

I send a curl message like this:

curl -X 'POST' -k 'https://localhost:8253/user-service3' \
-H 'Content-Type: application/soap+xml' \
-H 'accept: */*' \
-d '
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:user="http://user.ws.xx.com/">
   <soap:Header/>
   <soap:Body>
      <user:createUser>
         <arg0>abc</arg0>
       </user:createUser>
    </soap:Body>
 </soap:Envelope>'

what should I change in the curl command after adding the OAuth mediator at the beginning of the inSequence?

<oauthService remoteServiceUrl="https://testdomain.org:9444/services/" username="admin" password="admin"/> -->

I tried different ways but get errors from the wso2 identity server.
I add the Authorization header to curl.

-H 'Authorization : Bearer 8aa447a9-b929-355c-a885-1b92c5266051' \

But Micro Integrator shows this log:

INFO {LogMediator} - Direction: request, MESSAGE = Executing default 'fault' sequence, 
ERROR_CODE = 0, ERROR_MESSAGE = Error occured while validating oauth 2.0 access token, 
Envelope: 
<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:user="http://user.ws.xx.com/">
<soap:Body>
  <user:createUser>
     <arg0>abc</arg0>
  </user:createUser>
 </soap:Body></soap:Envelope>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韵柒 2025-01-31 03:31:34
  1. 是的,
  2. 它可以在
  3. 任何
  4. 地方添加授权标头到卷发。

卷曲命令是正确的。基于这个答案wso2产品的org.wso2.carbon.Identity.oauth.stub jar文件彼此不兼容。我以为我的问题是那个。

我将org.wso2.carbon.Identity.oauth.stub_6.4.111.jar文件从WSO2 Identity Server转移到WSO2 Micro Integator的WSO2/组件/插件目录。

cp wso2is-5.11.0/repository/components/plugins/org.wso2.carbon.identity.oauth.stub_6.4.111.jar wso2mi-4.1.0/wso2/components/plugins

然后更新了Micro Integrator的捆绑包。INFO文件:

vi wso2mi-4.1.0/wso2/components/micro-integrator-default/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

修改以下行:

org.wso2.carbon.identity.oauth.stub,6.1.0,../plugins/org.wso2.carbon.identity.oauth.stub_6.1.0.jar,4,true

对此:

org.wso2.carbon.identity.oauth.stub,6.4.111,../plugins/org.wso2.carbon.identity.oauth.stub_6.4.111.jar,4,true

重新启动Micro Integator服务器后,我的curl命令正常工作。

  1. Yes
  2. It can be anywhere
  3. Anything
  4. Add the Authorization header to curl.

The curl command is correct. Based on this answer I found out some of the wso2 product's org.wso2.carbon.identity.oauth.stub jar files are not compatible with each other. I thought maybe my problem is that.

I copied the org.wso2.carbon.identity.oauth.stub_6.4.111.jar file from the WSO2 Identity Server to the wso2/components/plugins directory of the WSO2 micro integrator.

cp wso2is-5.11.0/repository/components/plugins/org.wso2.carbon.identity.oauth.stub_6.4.111.jar wso2mi-4.1.0/wso2/components/plugins

Then updated the bundles.info file of the micro integrator:

vi wso2mi-4.1.0/wso2/components/micro-integrator-default/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

modified this line:

org.wso2.carbon.identity.oauth.stub,6.1.0,../plugins/org.wso2.carbon.identity.oauth.stub_6.1.0.jar,4,true

to this:

org.wso2.carbon.identity.oauth.stub,6.4.111,../plugins/org.wso2.carbon.identity.oauth.stub_6.4.111.jar,4,true

After restarting the micro integrator server, my curl command works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文