我使用Spring安全管理器使用带有基本身份验证的HTTP调用另一个mule流。我正在使用Mule 3.7并根据以下文档配置了所有内容:
https://docs.mulesoft.com/mule-user-guide/v/3.7/configuring-the-spring-security-manager
<spring:beans>
<ss:authentication-manager alias="authenticationManager">
<ss:authentication-provider>
<ss:user-service id="userService">
<ss:user name="${security.user.id}" password="${security.user.password}" authorities="ROLE_ADMIN" />
</ss:user-service>
</ss:authentication-provider>
</ss:authentication-manager>
</spring:beans>
<mule-ss:security-manager>
<mule-ss:delegate-security-provider name="memory-dao" delegate-ref="authenticationManager" />
</mule-ss:security-manager>
<http:listener-config name="httpLocalListener" host="${local.host}" port="${local.port}"
basePath="${local.path}" doc:name="HTTP Local Listener" connectionIdleTimeout="${local.timeout}"/>
<http:request-config name="httpLocalRequest" doc:name="HTTP Local Configuration" responseTimeout="${local.timeout}"
basePath="${local.path}" host="${local.host}" port="${local.port}">
<http:basic-authentication username="${security.user.id}" password="${security.user.password}"/>
</http:request-config>
<flow name="ServiceFlow1" processingStrategy="synchronous">
<http:listener config-ref="httpLocalListener" path="/status/*" doc:name="HTTP" allowedMethods="GET"/>
<http:basic-security-filter realm="${security.filter.realm}"/>
<!-- Omitted code -->
<http:request config-ref="httpLocalRequest" path="/ping/txt?siteId=#[sessionVars['siteId']]" method="GET" doc:name="HTTP" parseResponse="false">
<http:success-status-code-validator values="0..599"/>
</http:request>
</flow>
<flow name="ServiceFlow2" processingStrategy="synchronous">
<http:listener config-ref="httpLocalListener" path="/ping/txt" doc:name="HTTP" allowedMethods="GET"/>
<http:basic-security-filter realm="${security.filter.realm}"/>
<!-- Omitted code -->
</flow>
我收到以下错误(由于stackoverflow要求,我从http链接中删除了'//'):
错误2016-08-19 10:28:09,539 [[服务] .httpLocalListener.worker.02] org.mule.exception.DefaultMessagingExceptionStrategy:
消息:已注册的身份验证设置为org.mule.transport.http.filters.HttpBasicAuthenticationFilter但会话中没有安全上下文。端点http:0.0.0.0:8081 / services / ping / txt上的身份验证被拒绝。消息有效内容的类型为:NullPayload 键入:org.mule.api.security.UnauthorisedException 代码:MULE_ERROR - 2 JavaDoc:http:www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/security/UnauthorisedException.html 有效负载:{NullPayload}
异常堆栈是: 1.已注册的身份验证设置为org.mule.transport.http.filters.HttpBasicAuthenticationFilter但会话中没有安全上下文。端点http:0.0.0.0:8081 / services / ping / txt上的身份验证被拒绝。消息有效内容的类型为:NullPayload(org.mule.api.security.UnauthorisedException) org.mule.transport.http.filters.HttpBasicAuthenticationFilter:156(http:www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/security/UnauthorisedException.html)
任何帮助将不胜感激! 谢谢, 丹尼斯
答案 0 :(得分:0)
我曾经遇到过同样的问题,但是当我从Postman调用相同的URL时,问题就消失了,我们点击了服务以及基本身份验证的凭据。对于基于浏览器的常规测试,这同样不起作用,因为当您调用服务时,它需要基本身份验证的凭据,然后在下一个实例中为其提供弹出窗口。
HTTPs basic auth using Postman Client
AM不确定这是否有帮助,因为我的解释有点不成熟,但可能会帮助您更好地了解实施情况。我唯一可以说的是,它会抛出错误但会按预期工作。