DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • How to Set up OAuth JWT Flow and mTLS in the Salesforce Connector for a MuleSoft App
  • Create Proxy Application for Mule APIs
  • Implementing EKS Multi-Tenancy Using Capsule (Part 4)
  • Keep Your Application Secrets Secret

Trending

  • Event Driven Architecture (EDA) - Optimizer or Complicator
  • How to Create a Successful API Ecosystem
  • IoT and Cybersecurity: Addressing Data Privacy and Security Challenges
  • Distributed Consensus: Paxos vs. Raft and Modern Implementations
  1. DZone
  2. Software Design and Architecture
  3. Security
  4. How to Configure and Use Secure Properties In Mule 4

How to Configure and Use Secure Properties In Mule 4

Take a look at how to create and configure secure properties in Mule 4.

By 
Priyanka Paul user avatar
Priyanka Paul
·
Updated by 
Rob Gravelle user avatar
Rob Gravelle
·
Updated Apr. 11, 24 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
83.7K Views

Join the DZone community and get the full member experience.

Join For Free

Mule 4 is an advanced integration platform that enables seamless connectivity between various systems, applications, and data sources. In Mule 4, safeguarding sensitive data such as ClientID and Client Password is crucial for ensuring the security of your applications. Thankfully, MuleSoft provides a powerful solution in the form of the Secure Property module, allowing you to encrypt properties within .yaml or .properties files with ease. These files commonly contain critical information like Client ID, Secret, User ID, User Password, Splunk Tokens, OAuth Tokens, AWS Keys, and more. Encrypting this data is essential to prevent unauthorized access and uphold data protection standards.

This tutorial serves as a comprehensive guide to configuring and utilizing MuleSoft's Secure Property module effectively. By following the steps outlined in this tutorial, you'll learn how to encrypt sensitive information within property files, effectively shielding it from prying eyes and potential security threats. Whether you're a seasoned MuleSoft developer or just getting started with Mule 4, mastering Secure Properties will enhance the security posture of your applications and ensure compliance with industry standards. 

Let's dive in!

3 Steps to Creating Secure Properties in Mule 

Step 1: Create a configuration properties file.

Step 2: We can encrypt the whole file or encrypt individual property. For individual property, we can define secure properties in the file by enclosing the encrypted values between the sequence![value].

Step 3: Configure the file in the project with the Mule Secure Configuration Properties Extension module dependency. The file must point to or include the decryption key.

Step 1: Create a Configuration Properties File

The first task in securing configuration properties is to create a YAML configuration file (.yaml) or a Spring-formatted Properties file (.properties), where you define the properties in src/main/resources in your Mule project. The Mule Secure Configuration Properties extension module enables you to configure YAML or Properties file types.

Refer to the below artifacts for more information.

Open Anypoint Studio -> Go to Project Folder -> src/main/resources ->Select Create New file(File extension can be either .yaml or .properties)

 test.yaml

dev.properties


The following test.yaml, dev.properties files contain non-encrypted configuration properties values:

test.yaml (sample yaml file)

YAML
 
http:

port: "8081"

username: "Priyanka@pp"

password: "1254343654pp"

dev.properties (sample properties file)

Properties files
 
encrypted.value1= sfdsgfdgfj1234566

encrypted.value2= xyz123568abc


testPropertyA=testValueA

testPropertyB=testValueB

How to Define Secure Configuration Properties in The File

1. Add the Premium Security Connector in AnyPoint Studio:

Install new software

  1. Open Anypoint Studio -> Go to Help -> Select Install New Software 
  2. Click the Add button and it will open a window, provide the Name as Anypoint Enterprise Security and provide the location as http://security-update-site-1.4.s3.amazonaws.com and press ok.
  3. Go to the work drop-down and check Anypoint Enterprise Security — in the dropdown list. 
  4. Select it and select the Premium checkbox -> click Next — accept the policy and finish.

    Accept and click next
  5. Now go to the application and right-click on dev.properties and go to -> Open with -> Mule Properties Editor. Now your property file is open in the table editor view.

    Mule properties 
  6. Double-click on any key. It will open a new window. Now press the button Encrypt. In the next window specify the ‘algorithm’ (Algorithm used to encrypt/decrypt the value example- AES, Blowfish) and provide an encryption key(key size must be at least: '16' if it is AES algorithm) to encrypt.
    Encrypt
    Keys
    Decrypt
  7. Press the OK button.
  8. Similarly, you can encrypt the rest of the properties and open the file with a text editor.

Text editor

***Note: We can not encrypt the YAML file this way as after the encryption process all the property key alignment will be rearranged. ***

But the encryption of the YAML file can be achieved using Java encryption JAR.

Step 2: Encrypt Properties Using the Secure Properties Tool (jar)

  1. Download Secure-properties-tool.jar and put it into any folder location. Put the unencrypted yaml file in the same location.

    dev.properties 
  2. Use the following syntax to encrypt or decrypt all the content of a properties file:
Java
 
String level-------

java -cp secure-properties-tool.jar com.mulesoft.tools.SecurePropertiesTool

string <operation><algorithm><mode><key><input property>


java -cp secure-properties-tool.jar com.mulesoft.tools.SecurePropertiesTool string encrypt Blowfish CBC 123456789 PriyankaPaul


File/file level--------

java -cp secure-properties-tool.jar com.mulesoft.tools.SecurePropertiesTool

<method><operation><algorithm><mode><key><input file><output file>


java -cp secure-properties-tool.jar com.mulesoft.tools.SecurePropertiesTool file encrypt AES CBC 1234567812345678 dev-properties.yaml dev-out.yaml


Example of encryption:

             Encryption

Encryption


Step 3: Configure Secure Property Module and Dependency in The Project

  1. Add the secure property module in your project and configure the same. It can be downloaded from exchange also. Maven dependency:  
Java
 
<dependency>

<groupId>com.mulesoft.modules</groupId>

<artifactId>mule-secure-configuration-property-module</artifactId>

<classifier>mule-plugin</classifier>

<version>1.0.0</version>

</dependency>

File: Property file name 

Key: encryption /decryption key. This token will be passed in runtime configuration as program argument example: -Dtoken=1234567812345678

  1. Define the correct Algorithm and mode used for encryption.

Secure properties

Use of Secure Property in The Project

In any global configuration you can use this secure property as ${secure:: property.name}

In dwl we can also use secure property as p(‘secure:: property.name’)

In this below example we used http port as ${secure:: http.port} and decrypted_username_value: p('secure::username') 

Please note, the decryption process will be done implicitly by the Mule Runtime engine and this requires only the Key (passed as VM argument) which was used to encrypt the password and voilà you're done!!!!

HTTP Listener Config

 

Output Payload


Console view


Decryption successful

Mastering the use of Secure Properties in Mule 4 is essential for ensuring the security and integrity of your applications. By encrypting sensitive data within property files, you can effectively mitigate the risk of unauthorized access and safeguard your critical information. As you continue to leverage Secure Properties in your development projects, remember to adhere to best practices and stay vigilant against emerging security threats. With Secure Properties, you can fortify your applications against potential vulnerabilities and maintain compliance with industry standards. Start implementing Secure Properties today and take your Mule 4 applications to new levels of security and resilience. Happy coding!

security YAML MULE

Opinions expressed by DZone contributors are their own.

Related

  • How to Set up OAuth JWT Flow and mTLS in the Salesforce Connector for a MuleSoft App
  • Create Proxy Application for Mule APIs
  • Implementing EKS Multi-Tenancy Using Capsule (Part 4)
  • Keep Your Application Secrets Secret

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!