使用来自MULE的基本身份验证的REST服务

使用来自MULE的基本身份验证的REST服务,mule,integration,mule-studio,mule-component,Mule,Integration,Mule Studio,Mule Component,我正在使用mule的HTTP组件连接到restapi,它使用用户名和密码进行基本身份验证。我使用HTTP组件的“HTTP设置”选项卡提供身份验证详细信息、用户名和密码。但我认为它不起作用。 我做错什么了吗?有没有更好的方法调用具有基本身份验证的REST服务,如。以下是具有基本身份验证的REST服务的示例:- <mule-ss:security-manager> <mule-ss:delegate-security-provider name="memory-

我正在使用mule的HTTP组件连接到restapi,它使用用户名和密码进行基本身份验证。我使用HTTP组件的“HTTP设置”选项卡提供身份验证详细信息、用户名和密码。但我认为它不起作用。
我做错什么了吗?有没有更好的方法调用具有基本身份验证的REST服务,如。

以下是具有基本身份验证的REST服务的示例:-

  <mule-ss:security-manager>
        <mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />
    </mule-ss:security-manager>
    <spring:beans>
        <ss:authentication-manager alias="authenticationManager">
            <ss:authentication-provider>
                <ss:user-service id="userService">
                    <ss:user name="your username" password="your password" authorities="ROLE_ADMIN" />
                     <ss:user name="your username2" password="your password2" authorities="ROLE_USER" />
                </ss:user-service>
            </ss:authentication-provider>
        </ss:authentication-manager>    
    </spring:beans>

    <flow name="MainService" doc:name="MainService">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP">
           <mule-ss:http-security-filter realm="realm" />
           <mule-ss:authorization-filter requiredAuthorities="ROLE_ADMIN"/>  <!-- Restrict a particular group of users -->
        </http:inbound-endpoint>
        <jersey:resources doc:name="REST">
        <component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl"/>
        </jersey:resources>
    </flow>


用于从Mule连接现有的外部REST服务,请使用:-
http://username:password@主机/yourpath
在http出站端点中

以下是具有基本身份验证的REST服务示例:-

  <mule-ss:security-manager>
        <mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />
    </mule-ss:security-manager>
    <spring:beans>
        <ss:authentication-manager alias="authenticationManager">
            <ss:authentication-provider>
                <ss:user-service id="userService">
                    <ss:user name="your username" password="your password" authorities="ROLE_ADMIN" />
                     <ss:user name="your username2" password="your password2" authorities="ROLE_USER" />
                </ss:user-service>
            </ss:authentication-provider>
        </ss:authentication-manager>    
    </spring:beans>

    <flow name="MainService" doc:name="MainService">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP">
           <mule-ss:http-security-filter realm="realm" />
           <mule-ss:authorization-filter requiredAuthorities="ROLE_ADMIN"/>  <!-- Restrict a particular group of users -->
        </http:inbound-endpoint>
        <jersey:resources doc:name="REST">
        <component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl"/>
        </jersey:resources>
    </flow>


用于从Mule连接现有的外部REST服务,请使用:-
http://username:password@主机/yourpath
在http出站端点中

当您通过Mule http出站端点使用REST服务时,应将基本身份验证值设置为传出Mule消息的头属性

<flow name="consume_rest">
    .............
    ..........
    <set-property propertyName="Authorization" value="Basic Authorization String combination of Username and password" />
    <http:outbound-endpoint exchange-pattern="request-response" method="POST" responseTimeout="20000"
        host="localhost" path="rest.path" port="Port number" />
    .............
    .............
</flow>

.............
..........
.............
.............

希望这能有所帮助。

当您通过Mule HTTP出站端点使用REST服务时,应该将基本身份验证值设置为传出Mule消息的头属性

<flow name="consume_rest">
    .............
    ..........
    <set-property propertyName="Authorization" value="Basic Authorization String combination of Username and password" />
    <http:outbound-endpoint exchange-pattern="request-response" method="POST" responseTimeout="20000"
        host="localhost" path="rest.path" port="Port number" />
    .............
    .............
</flow>

.............
..........
.............
.............
希望这有帮助。

谢谢大家的回复!! 连接器上的用户名和密码用于您希望使用HTTP基本身份验证保护入站端点时使用

调用由basic auth保护的外部服务时,应使用uri方法

谢谢大家的回复!! 连接器上的用户名和密码用于您希望使用HTTP基本身份验证保护入站端点时使用


调用由basic auth保护的外部服务时,您应该使用uri方法

,感谢您的重播。我做了与您在代码段中提到的相同的事情,并且我使用相同的URL格式从任何客户端(包括mule HTTP)使用服务。但是,我想使用现有的MULE HTTP组件和“Advanced tab”中的基本身份验证选项,以便在组件中提及用户名和密码,我将使用普通url,其中不包含身份验证详细信息。这很简单。。。在http设置选项卡中的http出站端点中,您将找到用户名和密码选项。。。因此,在“高级”选项卡中,您只需将url放在“地址”部分,然后在“HTTP设置”选项卡中输入用户名和密码。。。最后,您的xml看起来像:-
Mule可以很好地处理包含身份验证凭据的url。但是,我尝试了与您上面提到的相同的方法。我的意思是在Mule连接器中设置用户名和密码,但会引发以下错误注册身份验证设置为org.Mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter,但会话上没有安全上下文。端点URL消息负载上的身份验证被拒绝的类型为:StringThat's Strange。。。它应该类似于:-
。。请检查方法。。。默认情况下,Http出站方法为POST。。请与您的休息服务部联系。。放置Web服务使用POST/GET/put等的方法。。最好使用Mule XML更新您的问题。。我们可以很容易地检测到这个问题……感谢您的重播。我已经做了与您在代码片段中提到的相同的事情,并且我使用相同的URL格式来使用来自任何客户端(包括mule HTTP)的服务。但是,我想使用现有的MULE HTTP组件和“Advanced tab”中的基本身份验证选项,以便在组件中提及用户名和密码,我将使用普通url,其中不包含身份验证详细信息。这很简单。。。在http设置选项卡中的http出站端点中,您将找到用户名和密码选项。。。因此,在“高级”选项卡中,您只需将url放在“地址”部分,然后在“HTTP设置”选项卡中输入用户名和密码。。。最后,您的xml看起来像:-
Mule可以很好地处理包含身份验证凭据的url。但是,我尝试了与您上面提到的相同的方法。我的意思是在Mule连接器中设置用户名和密码,但会引发以下错误注册身份验证设置为org.Mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter,但会话上没有安全上下文。端点URL消息负载上的身份验证被拒绝的类型为:StringThat's Strange。。。它应该类似于:-
。。请检查方法。。。默认情况下,Http出站方法为POST。。请与您的休息服务部联系。。放置Web服务使用POST/GET/put等的方法。。最好使用Mule XML更新您的问题。。我们很容易发现这个问题。。。