Basic Authentication in Mule 4

Basic Authentication is an authentication system built into the HTTP protocol. The request is sent with an Authorization header whose value is a Base64 encoded string of username and password combination.
It is a primary authentication mechanism. If the Authentication fails, the server responds with a 401 (Unauthorized) status code.
Process for Applying Basic Authentication in Mule 4
-
- Create a new project and add the Spring module.
- Add beans.xml under src/main/resources.
<ss:authentication-manager alias="authenticationManager"> <ss:authentication-provider> <ss:user-service id="userService"> <ss:user name="admin" password="{noop}admin" authorities="ROLE_ADMIN" /> <ss:user name="user" password="{noop}user" authorities="ROLE_USER" /> </ss:user-service> </ss:authentication-provider> </ss:authentication-manager>
Note: For Spring 5.x, all passwords need to be prefixed with {noop}
1. Add Spring Config and Spring Security manager global elements.

In Spring Config config refer to the beans.xml.
In Spring Security manager, provide the Name and Delegate reference as below:

- Create a new flow with HTTP listener to trigger the flow.
- Add Basic Security Filter just after the listener to validate the request, specify realm as mule.
- By this point, all incoming requests will be validated for the username-password combination but not the role. For this, add Authorization Filter from the Spring module.
- In the Required authorities textbox, write ROLE_ADMIN.
- By this point, the flow should look like below:

Deploy the app and hit the application from the postman or any REST client. Set Authorization to Basic Auth and provide username and password as required.

Since the required authority is ROLE_ADMIN, only requests with the admin’s credentials will be passed further. Requests with user credentials, though correct, will fail at Spring Authorization filter with MULE: NOT_PERMITTED error.
Change username/password to incorrect combination and requests will fail with HTTP: BASIC_AUTHENTICATION error.
Here’s all about basic authentication in Mule 4.
Recent Blogs

Boost LWC Performance with Debouncing
Introduction Lightning Web Components (LWC) is a modern framework for building fast and dynamic user interfaces on the Salesforce platform. However, one common challenge in web development, including LWC, is efficiently handling user input, especially when dealing with rapid or repetitive events, such as typing in a search field. This is where debouncing becomes an… Continue reading Boost LWC Performance with Debouncing
Boost LWC Performance with Debouncing
Introduction Lightning Web Components (LWC) is a modern framework for building fast and dynamic user interfaces on the Salesforce platform. However, one common challenge in web development, including LWC, is efficiently handling user input, especially when dealing with rapid or repetitive events, such as typing in a search field. This is where debouncing becomes an… Continue reading Boost LWC Performance with Debouncing

Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers
Introduction In order to succeed in today’s fast-paced business landscape, precision and speed define competitive advantage. For businesses, especially those managing complex product catalogs, ensuring accurate pricing on sales orders or custom lines can be a time-consuming and error-prone task. To overcome this challenge, Salesforce trigger handlers offer a powerful solution to automate the entire… Continue reading Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers
Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers
Introduction In order to succeed in today’s fast-paced business landscape, precision and speed define competitive advantage. For businesses, especially those managing complex product catalogs, ensuring accurate pricing on sales orders or custom lines can be a time-consuming and error-prone task. To overcome this challenge, Salesforce trigger handlers offer a powerful solution to automate the entire… Continue reading Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers

Connecting MuleSoft and Azure SQL with Entra ID
Introduction Establishing a secure connection between MuleSoft and Azure SQL Database can be challenging, especially if you are using Entra ID (formerly known as Azure Active Directory) for authentication. This blog walks through a fully working configuration for connecting to Azure SQL using ActiveDirectoryServicePrincipal in Mule runtime 4.7.4 with Java 8 — addressing driver setup,… Continue reading Connecting MuleSoft and Azure SQL with Entra ID
Connecting MuleSoft and Azure SQL with Entra ID
Introduction Establishing a secure connection between MuleSoft and Azure SQL Database can be challenging, especially if you are using Entra ID (formerly known as Azure Active Directory) for authentication. This blog walks through a fully working configuration for connecting to Azure SQL using ActiveDirectoryServicePrincipal in Mule runtime 4.7.4 with Java 8 — addressing driver setup,… Continue reading Connecting MuleSoft and Azure SQL with Entra ID

Understanding Salesforce Flow Approval Processes
Introduction: Salesforce introduced Flow Approval Processes in the Spring '25 release. This is an evolved version of the classic approval process model, powered by Flow Orchestrator. The new approach brings unprecedented flexibility, enabling the creation of dynamic, multi-level, and logic-driven approval workflows that are entirely declarative. Continue reading the blog to get a deeper understanding… Continue reading Understanding Salesforce Flow Approval Processes
Understanding Salesforce Flow Approval Processes
Introduction: Salesforce introduced Flow Approval Processes in the Spring '25 release. This is an evolved version of the classic approval process model, powered by Flow Orchestrator. The new approach brings unprecedented flexibility, enabling the creation of dynamic, multi-level, and logic-driven approval workflows that are entirely declarative. Continue reading the blog to get a deeper understanding… Continue reading Understanding Salesforce Flow Approval Processes