ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.87k stars 514 forks source link

Usage of StandardEncryptableEnvironment with additional active profile(s) and custom prefix and suffix breaks decryption #380

Open little-fish opened 8 months ago

little-fish commented 8 months ago

Hi there. I need to propagate some properties from the Environment to the System level so I am listening for ApplicationEnvironmentPreparedEvent event. So the only way is to register StandardEncryptableEnvironment within the SpringApplicationBuilder.

I use custom prefix and suffix specified in application.properties:

jasypt.encryptor.property.prefix=ENC://
jasypt.encryptor.property.suffix=

If only I use default Spring profile, all the properties from the event's environment instance are being decrypted just fine. The moment I specify some profile(s) in the spring.profiles.active property, none of the properties obtained from the event's environment are being decrypted (neither from application.properties nor from application-profile.properties).

If I switch back to the default prefix and suffix:

jasypt.encryptor.property.prefix=ENC(
jasypt.encryptor.property.suffix=)

decryption starts to work even with additional active profile(s).

I am using Spring Boot v3.2.1 (it happens with 3.1.x as well) and jasypt-spring-boot v3.0.5.