使用 WSO2 EI 中的基本身份验证处理程序保护 API

Securing APIs using basic authentication hander in WSO2 EI

我正在使用 API 作为我的后端服务和外部客户端之间的网关。我正在尝试通过使用 user/password 基本编码的基本身份验证来保护对我的 API 的访问。在遵循一些指南之后,我在我的 API 中添加了处理程序部分以管理 auth 模块。

我试过这个部分:

<handlers>
        <handler class="org.wso2.rest.BasicAuthHandler"/>
    </handlers>

Auth 处理程序对我有用,但即使我更改了用户管理员的密码,也只能使用 admin/admin 凭据。 我如何添加用户并让他使用特定凭据使用我的 API?

我按照以下步骤使用 WSO2 EI 管理控制台创建了一个用户。

  1. 单击左侧菜单选项卡中的配置,然后单击用户和角色[=36]下的添加 =].
  2. Select 添加新用户
  3. 输入用户名和密码并点击下一步
  4. Select 用户的角色并单击 完成(我选择了管理员权限)

然后我按照 1

中所述部署了 API
<api xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteAPI" 

context="/stockquote">
   <resource methods="GET" uri-template="/view/{symbol}">
      <inSequence>
         <payloadFactory media-type="xml">
            <format>
               <m0:getQuote xmlns:m0="http://services.samples">
                  <m0:request>
                     <m0:symbol></m0:symbol>
                  </m0:request>
               </m0:getQuote>
            </format>
            <args>
               <arg evaluator="xml" expression="get-property('uri.var.symbol')"/>
            </args>
         </payloadFactory>
         <header name="Action" scope="default" value="urn:getQuote"/>
         <send>
            <endpoint>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
      <faultSequence/>
   </resource>
   <handlers>
    <handler class="org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler"/>
   </handlers>
</api>

然后我可以使用带有新 username/password 的邮递员发送请求。

1 https://docs.wso2.com/display/EI650/Applying+Security+to+an+API#ApplyingSecuritytoanAPI-BasicAuthUsingaBasicAuthhandler

感谢您的回复。我试图在我的 api 中更改 "org.wso2.rest.BasicAuthHandler by "org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler" 并重新部署它。我收到此错误

Caused by: java.lang.ClassNotFoundException: org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler cannot be found by synapse-core_2.1.7.wso2v60

我似乎需要 .jar 文件才能加载它,但我找不到它。请问可以提供一个link下载吗?

我升级到 ESB 的 6.5.0 版本并且它工作正常。谢谢!