We have seen In Mule 4 Secure Configuration Properties Module that can be used to encrypt properties files or individual properties. In this article, we will see how to use Secure properties inside DataWeave 2 or in Mule 4 expression statements.
Things to know: If you need to see how to configure your Mule project to use the Secure Configuration Properties Module, and Encrypt Properties, I recommend you read the my article securing-configuration-properties-in-mule.
Once you have Secure Properties configured, you can read secure properties inside your xml configuration by prefixing secure:: namespace before the property name.
<set-payload value="${secure::encrypted.key}"/>
</flow>
Now, What about using it in DataWeave 2?
If you have used properties in DataWeave 1, you would know about a special function p(prop_name) that can be used inside DataWeave 1 script to read properties. The same function is available in Mule 4 and DataWeave 2.
Using in Expression:
<global-property name="prop" value="#[p('secure::encrypted.key')]"/>
Using in DataWeave 2.0:
%dw 2.0
output application/java
---
{
password: p('secure::encrypted.key')
}
Please find the sample Mule project in Github here
Happy learning :)
Things to know: If you need to see how to configure your Mule project to use the Secure Configuration Properties Module, and Encrypt Properties, I recommend you read the my article securing-configuration-properties-in-mule.
Once you have Secure Properties configured, you can read secure properties inside your xml configuration by prefixing secure:: namespace before the property name.
Use of secure prop in global property:
<global-property name="prop" value="my-${secure::property.key}"/>Use of Secure prop in Flow
<flow name="test-flow"><set-payload value="${secure::encrypted.key}"/>
</flow>
Now, What about using it in DataWeave 2?
If you have used properties in DataWeave 1, you would know about a special function p(prop_name) that can be used inside DataWeave 1 script to read properties. The same function is available in Mule 4 and DataWeave 2.
Using in Expression:
<global-property name="prop" value="#[p('secure::encrypted.key')]"/>
Using in DataWeave 2.0:
%dw 2.0
output application/java
---
{
password: p('secure::encrypted.key')
}
Please find the sample Mule project in Github here
Happy learning :)
No comments:
Post a Comment