Contact Free trial Login

Configure LDAP Provider for Spring Security

In Mule 4, you can either use a Spring Security LDAP provider to perform component authorization, or use it as a Mule security provider via the Spring module. Before you configure the LDAP provider, obtain the Spring JAR files and declare Spring beans.

Obtain JAR Files

The Mule software distribution provides the Spring JAR files you need in the <distribution>/lib/opt directory:

  • spring-ldap-core-2.3.2.RELEASE.jar

  • spring-security-config-4.2.6.RELEASE.jar

  • spring-security-core-4.2.6.RELEASE.jar

  • spring-security-ldap-4.2.6.RELEASE.jar

  • spring-security-web-4.2.6.RELEASE.jar

Declare Spring Beans

The DefaultSpringSecurityContextSource class is the access point for obtaining an LDAP context.
You must declare the Spring bean for DefaultSpringSecurityContextSource in a separate beans.xml file in your resources folder.

For example, you must set up an LDAP context source for use by the Spring Security authentication provider to search and authenticate your users. Also, you need to define an authentication-manager interface with an embedded ldap-authentication-provider class as in the following code sample:

	<beans xmlns=""

		<bean id="ldapContextSource" class="">
	        <constructor-arg value="ldap://localhost:389"/>
	        <property name="userDn" value="cn=admin,dc=example,dc=org"/>
	        <property name="password" value="admin"/>

	    <ss:authentication-manager alias="ldapAuthManager">


Configure the Mule Security Provider

The SpringSecurityProviderAdapter delegates to an AuthenticationProvider such as the LdapAuthenticationProvider. To configure the Mule security provider review the following example configuration that shows how you can achieve in Mule connector-level security and other security features that require one or more security providers.

	<spring:config name="Spring_Config" files="beans.xml" />

 		<spring:delegate-security-provider name="ldap-provider" delegate-ref="ldapAuthManager" />

The following example configuration references a basic HTTP security filter:

	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config">
		<http:listener-connection host="" port="8081" />

	<spring:config name="Spring_Config"  files="beans.xml" />

		<spring:delegate-security-provider name="ldap-provider" delegate-ref="ldapAuthManager" />

	<flow name="secureFlow">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/test" />

		<http:basic-security-filter doc:name="Basic security filter" securityProviders="#[['ldap-provider']]" realm="mule-realm"/>

		<ee:transform doc:name="Transform Message">
				<ee:set-payload><![CDATA[%dw 2.0
					output application/json
						"status": "ok"

Configure the Component Authorization

To configure the component authorization, declare the authorization-filter field as follows:

	<spring:authorization-filter requiredAuthorities="ROLE_TESTERS" />

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub