How to Configure HTTP Basic Auth for WSO2 EI proxy service

三世轮回 提交于 2021-01-29 15:10:36

问题


i am using WSO2 Enterprise Integrator 6.5.0 (lastest)

I need to enable HTTP Basic Authentication through a Proxy Service (SOAP, REST)

I have tried below resource - WSO2 EI and WSO2 Developer - Setup an ESB Proxy with http basic authentication

<?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>

But it does not work? i was expecting when i send wrong credentials,

The Proxy service would give me error?

below is the way i sending request :


回答1:


It seems, your requirement is to secure the proxy service, which will be invoked as REST, using Basic Auth. It is recommended to secure a proxy service using security policies when it is used as SOAP [1]. However, if you need to enable HTTP Basic Auth with a proxy service, you will need to write the custom implementation to authenticate the user, as it is not supported by default from the ESB. One of the following approaches can be used to achieve your requirement.

  1. Implement an API which is secured with Basic Auth and call the proxy service from that API. API handler implementation can be used to implement the authentication. Please refer [2] for API handler implementation.

  2. Use a synapse handler to process the authentication prior to the proxy service invocation. Refer [3] for synapse handler implementation. handleRequestInFlow() method of the synapse handler will be called prior to the ESB proxy service. Therefore, we can have the custom authentication implementation within handleRequestInFlow() of the handler and allow/restrict the proxy calls.

1 - https://docs.wso2.com/display/EI650/Applying+Security+to+a+Proxy+Service

2 - https://docs.wso2.com/display/ESB481/Securing+APIs#SecuringAPIs-BasicAuthUsingaBasicAuthhandler

3 - https://docs.wso2.com/display/EI6xx/Working+with+Synapse+Handlers




回答2:


Please refer to this. I think key should be corrected as Authorization instead of Proxy-Authorization.



来源:https://stackoverflow.com/questions/57784136/how-to-configure-http-basic-auth-for-wso2-ei-proxy-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!