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

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

我正在使用 WSO2 EI 6.3.0 和 WSO2 Developer Studio 3.8.0.
我正在使用 ESB 项目和其中的代理服务。

代理服务是一个简单的直通服务; 它从 webapp 接收请求并将其转发给 Soap Web 服务,从 WS 获取响应并给出 它返回到网络应用程序。

我按照本教程实现了此配置:
https://youtu.be/3OsuGhEMQgc

设置非常简单,一切正常,直到我找到 端点具有 http 基本身份验证的 Web 服务。

多亏了这篇文章,我让它成功了:
https://medium.com/@Jenananthan/wso2-esb-how-to-invoke-basic-auth-protected-endpoint-service-5bcdd8290cb4

下面是描述代理服务的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>

所以,这个配置(xml 文件) 有效,但我写了所有 无需使用 gui 的任何视觉或拖放元素即可启用基本身份验证的部分。

我的问题是:
1) 这是在代理服务上设置基本身份验证的正确方法吗?
2) 是否有任何 gui(拖放)元素可以直观地进行此设置?

注意:我不需要在两者之间进行基本身份验证 "clients" 和 ESB 代理服务;这个问题是关于基本的 ESB 代理服务和 "external" 网络服务之间的身份验证。

你所做的是正确的。要调用使用基本身份验证保护的服务,我们只需将授权 header 设置为消息。您可以使用 Header Mediator[1] 或 属性 mediator(您已经使用过)来执行此操作。没有专门为设置授权而设计的特殊中介(或工具中的 GUI 元素)header。

顺便说一句,您可以考虑将密码存储在 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