smallrye / smallrye-config

SmallRye Config - A Java Configuration library
Apache License 2.0
164 stars 119 forks source link

[smallrye-config-jasypt] Introduce new optional property to manage IvGenerator for jasypt secret key handler #1221

Open alex-kovalenko1982 opened 2 months ago

alex-kovalenko1982 commented 2 months ago

https://github.com/smallrye/smallrye-config/blob/b39e11207cbc9ede976065395c9f2bb7b89031b9/utils/jasypt/src/main/java/io/smallrye/config/jasypt/JasyptSecretKeysHandler.java#L16

At the moment, jasypt encryptor is fixed to new RandomIvGenerator(). Would be great to have an option to choose IvGenerator class when creating the encryptor. At least among RandomIvGenerator (default) and NoIvGenerator (optionally changed in the config).

Suggestion for a new property: smallrye.config.secret-handler.jasypt.iv-generator.enabled Default value: true

When nothing is set then the legacy behavior is in action: encryptor.setIvGenerator(new RandomIvGenerator()); and in case when new property set to false then the line above replaced with: encryptor.setIvGenerator(new NoIvGenerator());

radcortez commented 2 months ago

We can certainly consider adding such support.

Alternatively, it should be easy to provide your own secret key handler with the desired settings: https://smallrye.io/smallrye-config/3.9.1/config/secret-keys/