Search code examples
javamongodbspring-bootpassword-encryption

Storing configurable encrypted password of MongoDB User in Spring Boot


I have stored the password of MongoDB in spring.data.mongodb.password property in application.yml file in my spring boot project. I need to encrypt it so that it is not directly accessed by anyone. I do not intend to do any code changes for it but want to achieve it by some kind of spring boot configuration.


Solution

  • The issue got resolved. The problem was with the jasypt version. I was using jasypt-3.0.0 and it worked on 2.0.0. The full steps of configuring jasypt in the project can be found here :
    https://medium.com/@mail2rajeevshukla/hiding-encrypting-database-password-in-the-application-properties-34d59fe104eb

    I have passed the key in application.yml itself as the 3 mentioned methods were not working in my case. jasypt: encryptor: password: secretkey