有什么方法可以确保部署在最新 wso2ei 6.4.0 中的 REST 服务的基本身份验证?

Is there any way how to ensure basic authentication for REST services deployed in latest wso2ei 6.4.0?

我想使用 WSO2EI 6.4.0 作为 SOAP 和 REST 服务认证平台的代理(稍后可能会授权)。 我在 wso2 (https://docs.wso2.com/display/EI640/Applying+Security+to+an+API) 的文档中找到了解决方案,但不幸的是它不起作用。

将 "handler" 元素添加到服务定义中

<handlers>
    <handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
</handlers>

导致设计时出现异常(eclipse):

Invalid mediator <handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>    1d6bbce1-08e3-42d5-b550-6a4e224b0028.xml    /.tmp/.org.wso2.developerstudio.eclipse.esb line 15 org.wso2.developerstudio.eclipse.gmf.esb.diagram.synapseerror

忽略并部署此类 API,会使 API 停止工作。

有人可以帮忙吗?

您尝试在 WSO2EI 6.4.0 中为 API 添加基本身份验证的方式是正确的。 Developer studio 会像您提到的那样发出警告,但这应该不是问题。 Developer studio 将允许设置处理程序而不考虑警告,您应该能够创建一个包含 API 的复合应用程序并将其部署到 ESB。以下是带有 RESTBasicAuthHandler 的示例 API。

<?xml version="1.0" encoding="UTF-8"?>
<api context="/testapi" name="testapi" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST" protocol="https" url-mapping="/*">
        <inSequence>
            <send>
                <endpoint name="testapi_EP">
                    <http uri-template="http://localhost:8080/testapi"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
    <handlers>
        <handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
    </handlers>
</api>