admin管理员组

文章数量:1291024

Stack overflow gurus,

I have perused through multiple stack overflow links and gone through various articles but haven't got a solution for my specific use case. Here is my use case. I am using spring boot 3.4.1 with com.zaxxer:HikariCP:jar:4.0.3. My passwords are got from a vault (Cyberark) . We are using oracle and mongodb as the databases. When the system comes up , I have my DataSource bean(created through DataSourceBuilder) that gets the user name and password from the vault and it sets up the connection. Issue happens when after a few days when the password changes in the vault which could be anytime. My application connection pool gets a couple of incorrect username and password exceptions and then it locks after a few retries . Following are my questions.

  1. Since i am writing a library that is being used across a few projects, i want the library to handle this situation and reestablish connection with the new user/password. Is there a global way to do this (With REST we can do it with @ControllerAdvice , do we have something similar to that that i can do in the library ) so that i can introduce this exception handling at the library level.
  2. Once i have my exception handler i was thinking of using softEvictConnections and then resetting the datasource user and password . Do we have any clean code snippet that we can reuse for this as well ?
  3. I really think that the only way to fix this the right way is to handle the authentication exception and then reset the password so that i don't need to keep getting the passwords every time/few times for the edge case that the vault password could have changed as it could be weeks or months by the time the password gets changed. Are there any established patterns for dynamic password changes that we could lean on.

本文标签: Dynamic password change using Hikari CP to avoid database locks on a spring boot applicationStack Overflow