例如,在 Spring 中我使用以下代码:
<http pattern="/users(?!\/emails).*" request-matcher="regex" create-session="stateless" entry-point-ref="authenticationEntryPoint" use-expressions="true"
xmlns="http://www.springframework.org/schema/security">
<anonymous enabled="false" />
<intercept-url method="GET" pattern="/user(?:([^/](?s).*)?)" />
因此,在 Mule 上,我想在流程的开头添加安全性,或者(如果可能)配置
如果可能的话,我可以在社区版上执行此操作吗?
最佳答案
分点回答你的问题:-
是的,在Mule Community Edition中可以使用Spring security添加安全性,因为它支持基本身份验证
对于您的上述要求,您需要在 Mule 中实现 Spring security
Mule 可以使用Spring security进行配置,以提供带有用户名和密码的基本身份验证。每当您访问该服务时,它都会要求输入该服务的用户名和密码。
因此,这回答了您在流程开始时实现安全性的问题。
一个简单的例子是:-
<spring:beans>
<ss:authentication-manager alias="authenticationManager">
<ss:authentication-provider>
<ss:user-service id="userService">
<ss:user name="john" password="abc123" authorities="ROLE_ADMIN" />
<ss:user name="anon" password="anon" authorities="ROLE_ANON" />
</ss:user-service>
</ss:authentication-provider>
</ss:authentication-manager>
</spring:beans>
<mule-ss:security-manager>
<mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />
</mule-ss:security-manager>
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration" />
<flow name="SpringExampleFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<http:basic-security-filter realm="mule-realm"/>
<logger level="INFO" message="passed security successfully !!! " doc:name="Logger"/>
</flow>
</mule>
Spring Security 还可以配置为提供基于角色的支持,其中多个用户涉及 <mule-ss:authorization-filter/>
.
因此,您可以根据用户的角色过滤用户。
您可以在此处引用一些示例以获得更多关于它及其实现的想法:- http://confluex.com/blog/http-inbound-endpoint-basic-authentication/
和
https://developer.mulesoft.com/docs/display/current/Configuring+the+Spring+Security+Manager
关于java - 是否可以在 Mule Flow 中添加安全 url,例如 Spring Security?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31965582/