【问题标题】:How to Configure HTTP Basic Auth for WSO2 EI proxy service如何为 WSO2 EI 代理服务配置 HTTP 基本身份验证
【发布时间】:2019-09-04 08:11:48
【问题描述】:

我正在使用 WSO2 Enterprise Integrator 6.5.0(最新)

我需要通过代理服务(SOAP、REST)启用 HTTP 基本身份验证

我尝试过以下资源 - 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>

但它不起作用? 当我发送错误的凭据时,我期待,

代理服务会给我错误吗?

以下是我发送请求的方式:

【问题讨论】:

  • 您是在尝试调用中间有代理服务器的服务,还是只是需要基本身份验证的服务?如果它带有代理,您还必须在axis2.xml 中设置它。如果不启用连线日志docs.wso2.com/display/EI600/Debugging+Mediation 并检查是否设置了标头。
  • true
  • @Martin Hald 在axis2.xml 这些配置代码行被注释了吗?应该取消注释吗?
  • 如果你的 wso2 和后端之间有代理服务器,是的,那么你应该取消注释并配置它。

标签: wso2 wso2esb wso2-am wso2carbon wso2ei


【解决方案1】:

看来,您的要求是使用基本身份验证保护代理服务,该服务将作为 REST 调用。当代理服务用作 SOAP [1] 时,建议使用安全策略来保护代理服务。但是,如果您需要使用代理服务启用 HTTP 基本身份验证,则需要编写自定义实现来验证用户身份,因为 ESB 默认不支持它。可以使用以下方法之一来实现您的要求。

  1. 实现一个 API 由基本身份验证保护,并从该 API 调用代理服务。 API 处理程序实现可用于实现身份验证。 API处理程序实现请参考[2]

  2. 使用 突触处理程序 在代理服务调用之前处理身份验证。请参阅[3] 了解突触处理程序的实现。突触处理程序的 handleRequestInFlow() 方法将在 ESB 代理服务之前被调用。因此,我们可以在处理程序的 handleRequestInFlow() 中实现自定义身份验证,并允许/限制代理调用。

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】:

    请参考this。 我认为应该将 key 更正为 Authorization 而不是 Proxy-Authorization。

    【讨论】:

    • 我试过了,但是如何测试基本身份验证?当我发送带有/不带有基本身份验证的请求时。它仍然有效
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-10
    • 2012-03-11
    • 2013-10-06
    • 1970-01-01
    • 2022-07-08
    • 1970-01-01
    • 2016-11-16
    相关资源
    最近更新 更多