Reputation: 133
I'm using spring-boot application which has connection to a Mongo DB. The mongo data-source configured in the application.properties
file:
spring.data.mongodb.uri=mongodb://my_user:my_password@mongo_host:37017/mongo_db
I would like to encrypt my_password
part of the datasource.
Is there out of the box solution for that?
Thanks
Upvotes: 1
Views: 4157
Reputation: 1561
Since it is not resolving encrypted value from url, we can put it in it's own property and then reference that property in the url.
spring.data.mongodb.password=ENC(xIZhIV7nvOv5LqHfAKnvmjhyeecOT0lO)
spring.data.mongodb.uri=mongodb://user:${spring.data.mongodb.password}@mongo1.example.com:12345,mongo2.example.com:12345/mydb?replicaSet=rsdb
Upvotes: 2