Contact Free trial Login

Configuring the Spring Security Manager

MuleSoft recommends against deployments to Mule 3.8. Standard Support for this version ended on November 16, 2018, and Mule 3.8 will reach its End of Life on November 16, 2021, when Extended Support ends.

Use Spring Security 3.0 as a Security Manager inside Mule.

You can use any of the library’s security providers such as JAAS, LDAP, CAS (Yale Central Authentication service), and DAO. For more information on the elements you can configure for a security manager, see Security Manager Configuration Reference.

Single Security Provider Example

The following example illustrates how to configure a single security provider on Mule, in this case an in-memory database of users. To configure the provider, we set up a <user-service> element and the <authentication-manager> to which Mule delegates.

<mule xmlns:tls="" xmlns:http="" xmlns:tracking="" xmlns="" xmlns:doc=""

    <ss:authentication-manager alias="authenticationManager">
        <ss:user-service id="userService">
          <ss:user name="user" password="password" authorities="ROLE_ADMIN" />
          <ss:user name="anon" password="anon" authorities="ROLE_ANON" />

      <mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />

  <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration" />

  <flow name="SpringExample">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
      <logger level="INFO" message="## received" doc:name="Logger"/>
      <http:basic-security-filter realm="mule-realm"/>
    <logger level="INFO" message="## passed security" doc:name="Logger"/>

Adding Spring Security References

To make Spring Security work, you need to add XML schema declarations to your Mule app. Notice the above example includes the following references inside the root XML element:


Make sure you include these references as they are important and Studio does not add them automatically.

Security Filters

Security filters can be configured on an object to either authenticate inbound requests or attach credentials to outbound requests. For example, to configure an HTTP basic authorization filter on an HTTP connector, you would use the following connector security filter:

<mule-ss:http-security-filter realm="mule-realm"/>

When a request is received, the authentication header is read from the request and authenticated against all security providers on the Security Manager. If you only want to validate on certain providers, you can supply a comma-separated list of security provider names.

<mule-ss:http-security-filter realm="mule-realm" securityProviders="default,another"/>

The realm is an optional attribute required by some servers. You only need to set this attribute if required by the server on the other end.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub