In my spring boot application, at the startup, I am connecting to mongo db using MongoClient and using MongoCredential.createPlainCredential and thus supplying user-name and password.
Password is being fetched from hashicorp vault using rest call and supplied to mongoCredential.
The task, I am trying look for is – how can I update the password in the Mongoclient bean when password has rotated in the hashicorp vault ? Before achieving this, I want to understand how mongo db is using the password when the mongo connection is break down in the running application.
using these mogo dependencies
mongodb-driver-sync – 4.6.1
mongodb-driver-core – 4.6.1
Steps I performed as below
app-started and mongo db connection established
application working ok
I disconnected from network, so mongo db connection dropped
can see error in the logs ( expected )
re-connected to network,
mongo-db is connecting back automatically and see Opened Connection ( org.mongdb.driver.connection) but I don’t see it’s using password or how do I know it’s using password to reconnect or some token ? At this time of reconnection, I don’t see, debug point going into the MongoClient.
Once I know this, then only I will be able to update MongoClientBean and supply rotated password.
I read this Update MongoClient Credentials at runtime
and mainly this – https://jira.mongodb.org/browse/JAVA-3896 which closed with a comment – “this was closed because we’re converging on an OIDC-based solution to credential rotation.” – I am thinking, does my mongo java driver already using OIDC based approach for connection and using password only at very 1st connection and then all the subsequent re-connection is based on the token ?
if that’s the case, then I don’t have to care about updating MongoClient bean with rotated password ?
Please suggest. Thanks a lot.
NS22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.