我使用的API充当后端服务与外部客户端之间的网关。我正在尝试使用用户/密码基本编码通过基本身份验证来保护对我的API的访问。在遵循了一些指南之后,我在API中添加了处理程序部分,以便管理auth模块。
我尝试过此部分:
<handlers>
<handler class="org.wso2.rest.BasicAuthHandler"/>
</handlers>
Auth处理程序对我来说很好,但是即使我更改了用户admin的密码,也只能使用admin / admin凭据。我如何添加用户并让他使用具有特定凭据的API?
我按照以下步骤使用WSO2 EI管理控制台创建了一个用户。
然后,我按照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>$1</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>
然后我可以使用带有新用户名/密码的邮递员发送请求。
1 https://docs.wso2.com/display/EI650/Applying+Security+to+an+API#ApplyingSecuritytoanAPI-BasicAuthUsingaBasicAuthhandler
感谢您的回复。我试图在我的api中通过“ org.wso2.carbon.integrator.core.handler.RESTBasicAuthHandler”更改“ org.wso2.rest.BasicAuthHandler”,然后将其重新部署。我收到此错误