简体   繁体   English

WSO2 EI和WSO2 Developer - 使用http基本身份验证设置ESB代理

[英]WSO2 EI and WSO2 Developer - Setup an ESB Proxy with http basic authentication

I'm using WSO2 EI 6.3.0 and WSO2 Developer Studio 3.8.0. 我正在使用WSO2 EI 6.3.0和WSO2 Developer Studio 3.8.0。
I'm working with an ESB Project and a Proxy Service inside it. 我正在使用ESB项目和代理服务。

The Proxy service is a simple pass through service; 代理服务是一种简单的传递服务; it receives a request from a webapp and forward it to a Soap Web Service, gets the response from the WS and gives it back to the web app. 它接收来自webapp的请求并将其转发到Soap Web服务,从WS获取响应并将其返回给Web应用程序。

I realized this configuration following this tutorial: 我按照本教程实现了这个配置:
https://youtu.be/3OsuGhEMQgc https://youtu.be/3OsuGhEMQgc

The setup is very simple, everything worked fine until I found a web service whose endpoint has http basic authentication. 设置非常简单,一切正常,直到我找到一个端点具有http基本身份验证的Web服务。

I made it work thanks to this article: 由于这篇文章,我让它成功了:
https://medium.com/@Jenananthan/wso2-esb-how-to-invoke-basic-auth-protected-endpoint-service-5bcdd8290cb4 https://medium.com/@Jenananthan/wso2-esb-how-to-invoke-basic-auth-protected-endpoint-service-5bcdd8290cb4

Here follows the xml that describes the proxy service: 以下是描述代理服务的xml:

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="ProxyWithBasicAuth" startOnLoad="true" trace="disable" transports="https" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <endpoint name="endpoint_urn_uuid_xxxxxxxx-yyyy-zzzz-1111-234567892345">
            <address trace="disable" uri="https://here.goes.the.uri.of.the.ws.endpoint"/>
        </endpoint>
        <inSequence>
            <property value="this_is_the_username" name="username" scope="default" type="STRING"/>
            <property value="this_is_the_password" name="password" scope="default" type="STRING"/>
            <property expression="fn:concat($ctx:username,':',$ctx:password)" name="credentials" scope="default" type="STRING"/>
            <property expression="fn:concat('Basic ', base64Encode($ctx:credentials))" name="Authorization" scope="transport" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
        <faultSequence/>
    </target>
</proxy>

So, this configuration (xml file) is working , but I wrote all the section that enables basic auth without using any visual or drag and drop element of the gui. 所以,这个配置(xml文件) 正在运行 ,但我写了所有启用基本身份验证的部分,而不使用gui的任何视觉或拖放元素。

My questions are: 我的问题是:
1) is this the right way to setup basic auth on a proxy service? 1)这是在代理服务上设置基本身份验证的正确方法吗?
2) is there any gui (drag and drop) element that allows to do this setup visually? 2)是否有任何gui(拖放)元素允许在视觉上进行此设置?

Note: I do not need to struggle with basic authentication between "clients" and the ESB Proxy Service; 注意:我不需要在“客户端”和ESB代理服务之间进行基本身份验证。 this question is about basic authentication between ESB Proxy Service and an "external" web service. 这个问题是关于ESB代理服务和“外部”Web服务之间的基本身份验证。

What you have done is correct. 你所做的是正确的。 To invoke a service secured with Basic Auth, we just have to set the Authorization header to the message. 要调用使用Basic Auth保护的服务,我们只需将Authorization标头设置为消息。 You could use Header Mediator[1] or the Property mediator (as you have already used) to do that. 您可以使用Header Mediator [1]或Property mediator(如您已使用过的那样)来执行此操作。 There is no special Mediator (or a GUI element in the Tool) specifically designed for setting the Authorization header. 工具中没有专门用于设置授权标头的特殊介体(或工具中的GUI元素)。

Btw, you could consider storing passwords in the secure-vault[2] rather than having it in plain text in the Synapse configuration. 顺便说一句,您可以考虑将密码存储在secure-vault [2]中,而不是在Synapse配置中以纯文本形式存储密码。

[1] https://docs.wso2.com/display/EI640/Header+Mediator [2] https://docs.wso2.com/display/EI640/Working+with+Passwords+in+the+ESB+profile [1] https://docs.wso2.com/display/EI640/Header+Mediator [2] https://docs.wso2.com/display/EI640/Working+with+Passwords+in+the+ESB+profile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM