Replies: 5 comments 8 replies
-
Yes. The Vault config source now uses a separate client to get around issues with using CDI during application boot/init.
Your logic seems sound. A reproducer would definitely be helpful. I'm going to look at the previous version's logic that this code attempted to reproduce and see why |
Beta Was this translation helpful? Give feedback.
-
@wiebeck Also, thank you for the very detailed analysis. I am in the middle of quite a few other things and this will help get this resolved ASAP. Another thing you might be able to help with. Can you look at |
Beta Was this translation helpful? Give feedback.
-
@wiebeck Actually, |
Beta Was this translation helpful? Give feedback.
-
@wiebeck I've opened #263 with a fix for #262. Are you able to test this PR to see if it fixes your issue? |
Beta Was this translation helpful? Give feedback.
-
@wiebeck I merged #263. You should be able to build with the latest |
Beta Was this translation helpful? Give feedback.
-
I am currently trying to figure out why my application (running on Kubernetes, using Vault as config source and as provider for dynamic database credentials) runs into situations where the Vault token is expired, so I enabled debug logging for the
io.quarkus.vault
category.First of all I noticed that the actual client token gets logged in clear text but this will be fixed in v4.0.1 via #258.
The second thing that made me wonder is that my application actually authenticates twice to Vault. One time to read config properties and another time to request database credentials:
Note the different threads (
main
vs.agroal-11
) and TTL of 2 hours. As noticed theVaultCachingTokenProvider
logs the actual token, so I can see that my application now "knows" about two different Vault tokens.Is this to be expected? Because I would have expected that the app only uses one single Vault client token no regardless of accessing config source via KV engine or dynamic database credentials.
Now to my main concern: I have configured multiple config sources and I noticed the following in the log when Quarkus needs to refresh the properties from Vault:
Here the same token is being used to refresh the config sources but notice that the
expires at
timestamp always shows a new time, some milliseconds apart. I really doubt that the token got extended multiple times in a row, so I looked at the source. Inio.quarkus.vault.client.auth.VaultCachingTokenProvider#apply
after the cached token (in my casenon-null
) has been determined there comes the following code block that extends the token if necessary (or requests a new one in case we don't have one) and caches the result again:Now take a look at
this.cachedToken.set(vaultToken.cached());
. In case my existing token is still valid and does not need to be extended I expect the cached token not to change at all but when you followvaultToken.cached()
you see that the result is a token that gets a new creation timestamp, which IMHO is simply wrong.You're only passing the
leaseDuration
(2 hours in my case) and theinstantSource
(I assume that's usuallyInstantSource.system()
), so following thesuper
constructor leads to:So the new cached token is a token that has an updated creation timestamp and the same lease duration as the original token. This will make the Vault extension think that the token is always fresh and valid even if it slowly expires as it doesn't actually get extended.
The result is that after 2 hours when at some point my app wants to refresh the config properties I encounter a 403 error when accessing Vault secrets:
Before trying to provide a reproducer I first like to know what you think about this. Maybe I am missing something?
Regards
Beta Was this translation helpful? Give feedback.
All reactions