【问题标题】:Is it possible to add a security url in a Mule Flow, like Spring Security?是否可以在 Mule Flow 中添加安全 URL,例如 Spring Security?
【发布时间】:2017-07-07 19:57:40
【问题描述】:

例如,在 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 上,我想在流程的开头添加安全性,或者(如果可能的话)配置 标签。

如果可能,我可以在 Community Edition 上执行此操作吗?

【问题讨论】:

    标签: java spring-security mule mule-studio


    【解决方案1】:

    分点回答你的问题:-

    1. 是的,可以在 Mule Community Edition 中使用 Spring security 添加 security,因为它支持 基本身份验证
      对于您的上述要求,您需要在 Mule 中实现 Spring security
      Mule 可以配置 Spring security 以提供带有 usernamepassword 的 Basic Authentication。

    2. 每当您点击该服务时,它都会询问该服务的用户名密码
      因此,这回答了您在流程开始时实施安全性的问题。

    一个简单的例子是:-

    <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 也可以配置为提供基于角色的支持,其中多个用户涉及&lt;mule-ss:authorization-filter/&gt;
    因此,您可以根据用户的角色过滤用户。

    你可以参考这里的一些例子来获得更多关于它的想法和它的实现:-http://confluex.com/blog/http-inbound-endpoint-basic-authentication/

    https://developer.mulesoft.com/docs/display/current/Configuring+the+Spring+Security+Manager

    【讨论】:

    • 我已经编辑并跟踪了我之前的答案.. 现在的答案是更具体的用户需求
    • 但是,我可以添加自定义过滤器而不是基本安全过滤器吗?
    • 您想添加什么类型的自定义过滤器? Spring 安全性将很容易实现...对于企业版 OAuth 有
    • 我需要的是:我有一个用于认证的API,当认证将被调用时,Mule 将返回一个SessionID。 Mule 会处理这个会话,并且在认证之后,请求应该根据角色被&lt;mule-ss:authorization-filter/&gt; 过滤。
    • 是的,您可以使用它,也可以在您的 api 中编写代码以返回会话 ID,并可以接受您请求中的角色并对其进行验证。您可以配置任何您喜欢的内容
    猜你喜欢
    • 2023-01-29
    • 1970-01-01
    • 2016-04-20
    • 1970-01-01
    • 2014-10-18
    • 2011-09-07
    • 2016-11-24
    • 2015-09-19
    • 1970-01-01
    相关资源
    最近更新 更多