Mule ESB和基本身份验证

时间:2014-08-01 19:00:54

标签: mule http-basic-authentication

我写了一个接受JSON的流程,现在我想添加http身份验证。我想接受HTTP基本身份验证uid和pw。

所以我首先从Hellow World计划入手,如下:

<?xml version="1.0" encoding="UTF-8"?>
<mule version="EE-3.5.0" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
    <flow doc:name="HelloWorldFlow1" name="HelloWorldFlow1">
        <http:inbound-endpoint doc:description="This endpoint receives an HTTP message." doc:name="HTTP" exchange-pattern="request-response" host="localhost" port="8081"/>
        <set-payload doc:description="This processor sets the payload of the message to the string 'Hello World'." doc:name="Set Payload" value="Hello World"/>
    </flow>
</mule>

我用以下程序测试:

C:\curl>curl -H "Content-Type: application/json" -u uida:pw -d {"first":"Steven"
} http://localhost:8081
Hello World
C:\curl>

这是有效的,因为在eflow中没有配置基本身份验证,所以它忽略了&#34; -u uid:pw&#34;我发送了curl命令

现在我按照以下方式更改流程(我在&#39; Http设置 - &gt;用户&#39;字段中输入&#39; uid&#39;以及&#39; pw&#39;在& #39; Http Seetings-&gt; GUI上的密码&#39;字段

<?xml version="1.0" encoding="UTF-8"?>
<mule version="EE-3.5.0" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
    <flow doc:name="HelloWorldFlow1" name="HelloWorldFlow1">
        <http:inbound-endpoint doc:description="This endpoint receives an HTTP message." doc:name="HTTP" exchange-pattern="request-response" host="localhost" port="8081" password="pw" user="uid"/>
        <set-payload doc:description="This processor sets the payload of the message to the string 'Hello World'." doc:name="Set Payload" value="Hello World"/>
    </flow>
</mule>

现在,当我测试时,我得到以下内容:

C:\curl>curl -H "Content-Type: application/json" -u uida:pw -d {"first":"Steven"
} http://localhost:8081
Cannot bind to address "http://127.0.0.1:8081/" No component registered on that
endpoint

我已经反复这样做了,但我得到了同样的回应。

我应该设置另一个字段吗?关于如何解决这个问题的任何想法?

由于

1 个答案:

答案 0 :(得分:2)

userpassword属性对入站HTTP端点无效,它们仅适用于出站。

Mule使用Spring Security进行身份验证。用户指南中详细介绍了这一点:http://www.mulesoft.org/documentation/display/current/Configuring+the+Spring+Security+Manager,包括您需要放入HTTP入站端点的http-security-filter示例。