ulisesbocchio / jasypt-spring-boot

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

when implements ImportBeanDefinitionRegistrar,the password is encrypted,why? #243

Closed wuyou201400 closed 3 years ago

wuyou201400 commented 3 years ago

public class DynamicDataSourceRegister0 implements ImportBeanDefinitionRegistrar,EnvironmentAware { @Override public void setEnvironment(Environment environment) { String password = environment.getProperty("spring.datasource.password"); System.out.println("EnvironmentAware-jasypt password:"+password); }

liaomengge commented 3 years ago

这个是在框架解密前做的,肯定还是加密的值啊,建议看下源码 ~

ulisesbocchio commented 3 years ago

According to the docs of ImportBeanDefinitionRegistrar:

Interface to be implemented by types that register additional bean definitions when processing @Configuration classes. Useful when operating at the bean definition level (as opposed to @Bean method/instance level) is desired or necessary.

This means your method it's getting invoked earlier than this library kicks in. For this situation, you need to feed an encrypt able environment directly into your spring boot app https://github.com/ulisesbocchio/jasypt-spring-boot#custom-environment