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

CPQ to Agentforce Revenue Management: Why Your Next Migration Should Start with Business Strategy, Not Configuration
Every technology platform eventually evolves. The organizations that realize the greatest value are not the ones that migrate first they are the ones that use the transition to rethink how their business operates. That is exactly where many organizations find themselves today as they plan their move from Salesforce CPQ to Agentforce Revenue Management. The… Continue reading CPQ to Agentforce Revenue Management: Why Your Next Migration Should Start with Business Strategy, Not Configuration
CPQ to Agentforce Revenue Management: Why Your Next Migration Should Start with Business Strategy, Not Configuration
Every technology platform eventually evolves. The organizations that realize the greatest value are not the ones that migrate first they are the ones that use the transition to rethink how their business operates. That is exactly where many organizations find themselves today as they plan their move from Salesforce CPQ to Agentforce Revenue Management. The… Continue reading CPQ to Agentforce Revenue Management: Why Your Next Migration Should Start with Business Strategy, Not Configuration

Integrating Salesforce with MuleSoft: A Practical Guide
Salesforce and MuleSoft integrations are often presented as straightforward connector setups but the real complexity lies in authentication design and access control. This guide walks through a clean, production-ready approach to setting up a secure integration between Salesforce and MuleSoft. Why This Matters More Than Ever With recent updates in Salesforce, basic authentication is being… Continue reading Integrating Salesforce with MuleSoft: A Practical Guide
Integrating Salesforce with MuleSoft: A Practical Guide
Salesforce and MuleSoft integrations are often presented as straightforward connector setups but the real complexity lies in authentication design and access control. This guide walks through a clean, production-ready approach to setting up a secure integration between Salesforce and MuleSoft. Why This Matters More Than Ever With recent updates in Salesforce, basic authentication is being… Continue reading Integrating Salesforce with MuleSoft: A Practical Guide

Designing for Reality: Integrating 837 Claims When X12 Meets Production
Designing 837 Claim Integration for Real-World Healthcare Systems When it comes to 837 claim integration, most architects assume the X12 specification guarantees predictability. On paper, the 837 Professional, Institutional, and Dental transactions look clean and orderly. In production? Not even close. Real-world 837 files behave differently across trading partners. Loops appear conditionally. Repeatable segments shift… Continue reading Designing for Reality: Integrating 837 Claims When X12 Meets Production
Designing for Reality: Integrating 837 Claims When X12 Meets Production
Designing 837 Claim Integration for Real-World Healthcare Systems When it comes to 837 claim integration, most architects assume the X12 specification guarantees predictability. On paper, the 837 Professional, Institutional, and Dental transactions look clean and orderly. In production? Not even close. Real-world 837 files behave differently across trading partners. Loops appear conditionally. Repeatable segments shift… Continue reading Designing for Reality: Integrating 837 Claims When X12 Meets Production

AI-Driven PDF Parsing in Salesforce
Introduction For the current digital ecosystem, data is an important aspect for decision-making. Yet, for many organizations, a significant portion of this valuable data remains locked away in unstructured formats. Organizations handle thousands of PDF documents daily — ranging from contracts and invoices to lab reports, quotations, and service agreements. Traditionally, extracting structured data from… Continue reading AI-Driven PDF Parsing in Salesforce
AI-Driven PDF Parsing in Salesforce
Introduction For the current digital ecosystem, data is an important aspect for decision-making. Yet, for many organizations, a significant portion of this valuable data remains locked away in unstructured formats. Organizations handle thousands of PDF documents daily — ranging from contracts and invoices to lab reports, quotations, and service agreements. Traditionally, extracting structured data from… Continue reading AI-Driven PDF Parsing in Salesforce