Contact Us 1-800-596-4880

Configuring Basic Security Filter for HTTP Connector

Consider a Mule app that exposes an API for accessing sensitive customer information, such as personal details and order history. To secure this API, you want to implement basic security using a username and password combination. The Anypoint Platform for HTTP (HTTP Connector) Basic Security Filter operation enables you to enforce basic authentication.

The following example illustrates how to configure the Basic Security Filter operation to ensure that only authorized users can access the protected API.

  1. In Anypoint Studio, add an HTTP Listener source to your flow. This serves as the entry point for incoming API requests.

  2. Drag the Basic Security Filter operation after the HTTP Listener. The operation validates the username and password provided in the request headers.

  3. Select the Basic Security Filter operation from your flow.

  4. Configure the Basic Security Filter operation with the desired username and password credentials.

  5. Continue building your Mule flow by adding the logic for handling API requests, retrieving customer information, or performing other operations.

HTTP Basic Security Filter configuration window in Anypoint Studio

In the Configuration XML, the configuration looks like this:

 <http:listener-config name="HTTP_Listener_config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<flow name="testFlow1">
		<http:listener config-ref="HTTP_Listener_config" path="/test"/>
		<http:basic-security-filter realm="MuleRealm">
			<http:security-providers >
				<http:security-provider value="test" />
			</http:security-providers>
		</http:basic-security-filter>
        <!-- Add your API logic here -->
    </flow>
View on GitHub