-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot renew a MongoDB lease due to lease expired #256
Comments
Thanks a lot for the detailed report. Credentials requested by Spring Cloud Vault are not rotated. They are only renewed. The reason is that properties are exposed as config properties and the components that use configuration properties do not expect a change of properties during runtime. In the example above, we see log output that keeps the secret alive (renewal). Once the terminal TTL expires, the last renewal fails correctly with an error. You can request a rotating secret for MongoDB credentials but then you are in charge to control the MongoDB client lifecycle. There is no possibility to check whether MongoDB or other, similar resources, are currently executing queries so the underlying resource could be swapped with a fresh one. See also: |
Thanks a lot for your reply. But I'm afraid the case is nothing with secret rotation. According to the vault guide Create Role, the |
Renewal is that what you're seeing in the logs. Once a lease exceeds |
Thus, in this case, I should rotate a new lease to replace the revoked timeout lease, and I should be in charge to control the new lease. Am I right? |
Yes. See the May I close this ticket or is there anything else I can assist you with? |
I got it. And may I have just one more further question please? How about the secret id when it reaches the TTL? Should I also take charge to control the rotation of secret id? |
I assume you're talking about If you provide a static secret Id with a TTL, then Spring Vault can re-login within the TTL timeout. After that time, you need to provide a new secret Id. If you use pull-mode for the secret Id, then Vault can obtain a fresh secret Id itself and properly re-login. Closing this one as the questions are answered. |
@tonny1983 I know that the thread is a bit old already. I hope it it is still helpful for you or other people stumbling across the same question. |
@tonny1983 The follow-up post about how to rotate expiring relational Spring Cloud Vault database credentials without downtime is available: Heavy Rotation of Relational Hashicorp Vault Database Secrets in Spring |
@usr42 I would like to see a blog post on rotating MongoDB secret. |
@mp911de, @usr42 apparently this is still the case in 2022. Unfortunately, it is difficult to see from the documentation that dynamic secrets, which are probably the most common reason for using vault, cannot be automatically rotated from However, the following passage can be found in the current documentation:
Do you think it would be a useful extension to mention these restrictions in the documentation? |
Good point, it makes sense to reword the sections to reflect that rotation works only in some cases (such as AWS). |
How To Reproduce
Start vault server in dev mode
vault server -dev
Enable app-role
vault auth enable approle
Import a policy
vault write sys/policy/demo-policy [email protected]
(the file is listed later)Create an app role with unlimited tokens and secret ids
vault write auth/approle/role/readwrite secret_id_ttl=100m token_num_uses=0 token_ttl=100m token_max_ttl=100m secret_id_num_uses=0 policies="default,demo-policy"
Enable database secrets
vault secrets enable database
Configure MongoDB connection info.
vault write database/config/vault-mongodb-demo-database plugin_name=mongodb-database-plugin allowed_roles="readwrite" connection_url="mongodb://{{username}}:{{password}}@[myip]/admin?ssl=false" username="[myusername]" password="[mypassword]"
Configure a role that maps a name
vault write database/roles/readwrite db_name=vault-mongodb-demo-database creation_statements='{ "db": "vaultdemo", "roles": [{ "role": "dbOwner" }, {"role": "readWrite", "db": "vaultdemo"}] }' default_ttl="1m" max_ttl="1m"
Get roleid which will be the value of
spring.cloud.vault.app-role.role-id
vault read auth/approle/role/readwrite/role-id
Get secret id which will be the value of
spring.cloud.vault.app-role.secret-id
vault write -f auth/approle/role/readwrite/secret-id
Spring Boot
2.0.6.RELEASE
Spring Cloud
Finchley.SR1
Spring Vault core
2.1.1.BUILD-SNAPSHOT
Vault
v0.11.4
Error Description
After about 1 minute from starting the demo app, I got the following exception:
And error message also shows from vault server:
Besides, before the exception, there's some info of spring vault scheduling the renewal:
I'm using the version of
2.1.1.BUILD-SNAPSHOT
because before the version I got 403 forbidden error when renewing the secret just as the question and the issue #255 described, and using the version according to the comment in #255 . However, it seems the problem reported in spring vault #319 still occurs in spring cloud vault.The text was updated successfully, but these errors were encountered: