Im working on a project that uses Spring Data Cassandra (for simplicity, “SDC” from now on) and we have been working on the integration with Spring Vault so we can generate dynamic credentials and rotate them. We are receiving the new credentials from Vault, but at that point we were expecting to find in the SDC API a way to update the credentials to connect to the database, but we saw it is not possible (on the other hand, we don’t know if other Spring Data projects offer that functionality).
We took a look to how SDC uses the Datastax Java driver. A CqlSession object is created at startup and it contains the credentials, but they cannot be modified. So we come up with a solution composed by the following steps.
- Update CassandraProperties with the new user and password
- Create a new CqlSession object that uses the new credentials.
- Update the CqlTemplate and ReactiveCqlTemplate session factories with the new session, so new operations to the data base will use the new credentials
- Close the old session, so no new requests are accepted and the ones being executed are allowed to complete.
I think this functionality seems something that could be offered by SDC, instead of being implemented by the user. Updating connection credentials is quite a common operation.
So specific questions:
- Is there any plan to include a similar feature ("update credentials") in future versions of SDC? Or is this a feature that fits better under the scope of the datastax java client?
- Has anyone faced this problem before?