Encrypt your Properties with Jasypt and Spring Boot

Published: 17 April 2023
on channel: Fast and Simple Development
7,654
142

Quickly Encrypt your Properties with Jasypt for your Spring Boot application.

Using the ENC() in your application.properties file allows you to access the secure content.

You need to add the following annotion, I added it in the Application class
@EnableEncryptableProperties


The password that is used to encrypt is passed in the runtime arguements can also be an Environment Variable.

-Djasypt.encryptor.password=secretKey

export JASYPT_ENCRYPTOR_PASSWORD=secretKey

pom.xml dependency

‹dependency›
‹groupId›com.github.ulisesbocchio‹/groupId›
‹artifactId›jasypt-spring-boot-starter‹/artifactId›
‹version›3.0.4‹/version›
‹/dependency›


Build plugin to encrypt on the command line

‹plugin›
‹groupId›com.github.ulisesbocchio‹/groupId›
‹artifactId›asypt-maven-plugin‹/artifactId›
‹version›3.0.5‹/version›
‹/plugin›

Note: Always externalize your application.properties file, even with encrypted params you do not want to check them in and do not want to build a jar file with the params, keep configuration outside the jar file.


Jasypt Spring Boot Starter Documentation

https://github.com/ulisesbocchio/jasy...



More can be found on my Udemy classes: https://www.udemy.com/user/tomjay2

Find this and more on my GitHub: https://github.com/ThomasJay

As well as my Web site: https://www.thomasjayconsulting.com

I want to help you learn and find an Amazing Job or just increase your Skills.

#java #SpringBoot #software