Open carlzogh opened 1 month ago
Hey @heatherezell @VioletHynes - could you please confirm if this is the expected behavior or if this is something we've misconfigured in the Proxy?
This seems like expected behaviour today. However, I agree it's unfortunate, and it'd be great if we could avoid this. To your point here:
Vault Proxy is able to persist its authentication token and not need to perform a mandatory token lookup / refresh on startup if it is still valid.
This is the crux of the issue, and I'd call this the problem as opposed to the persistent cache itself. This is something that would provide great value with or without persistent caching.
Another big benefit here is that if my Auto Auth token has a 1 day TTL and I restart Agent/Proxy five times a day, we make one token instead of five.
This has been a known potential enhancement for a while, but I'm going to give this a think and see if there's any smart, easy way we can address this. The challenge is of course safely persisting a token, and ideally any way we'd want to do this in a way that provides value to users who are and aren't using caching. I can't promise anything here timeline wise (like I've said, this has been a known FR for a while) but I will promise I'll give this a good think at the very least.
Thanks for the issue and food for thought!
Thanks @VioletHynes, that makes sense.
In our use-case we wish to rely on Vault Proxy as a component in our system that provides statically stable access to cached (remote) Vault Server secrets, and unfortunately this is likely a deal-breaker for us. Would you happen to know if there is a workaround for us achieving this outcome today, until "proper" support for this is added to Vault?
Appreciate your help as always!
Proxy isn't designed to be ran in an airlocked environment without any access to Vault ever. While it is designed to be resilient to downtime, it's not designed to be ran in an environment with no Vault access. This kind of feature to me would enable two things:
I don't see this so much as enabling a new use case (I don't know if we want to support Proxy in a completely airlocked environment) as I do bolstering the already strong story Proxy has for resilience to downtime.
The way we'd probably add this is by utilizing the token sink feature, which can already be configured to store a token. If I were implementing this I'd add some kind of option to token sinks that allows Agent/Proxy to check these for tokens before auto-authing. There are some complications that make it not a trivial change, and it's a pretty significant change to their operation.
There's a chance I get some free time to think about what the implementation of this might look like or potentially implementation over the next few days/weeks, depending on how busy I am. If you do want to increase the priority of such a feature, you can do so via our existing support/account management channels.
Thanks, Violet
Thanks Violet - to clarify, we're not looking to run in an airlocked environment, however we want to be resilient and allow "offline restarts" of Vault Proxy during temporary downtime / unavailability of Vault Server.
Describe the bug Vault Proxy with persistent static secrets cache & auto-auth enabled is unable to start up offline without trying to connect to Vault Server to renew its token.
Unless the issue is misconfiguration on our side, this prevents us from relying on Vault Proxy for static stability / availability in cases when the Vault Proxy process is restarted during Vault Server unreachability.
To Reproduce
==> Vault Proxy configuration:
2024-09-06T09:39:38.514Z [INFO] proxy.cache: cache configured: cache_static_secrets=true disable_caching_dynamic_secrets=true 2024-09-06T09:39:38.516Z [TRACE] proxy.cache.cacheboltdb: closing bolt db: path=/var/run/cache/vault-agent-cache.db 2024-09-06T09:39:38.519Z [TRACE] proxy.cache.leasecache: restored token: id=0EHrt 2024-09-06T09:39:38.519Z [TRACE] proxy.cache.leasecache: restored token: id=0eE2O ... other tokens 2024-09-06T09:39:38.521Z [TRACE] proxy.cache.leasecache: restored token: id=zBDQx 2024-09-06T09:39:38.521Z [TRACE] proxy.cache.leasecache: restoring static secret index: id=b0b444679a0300f2cf23b576d35637fae0b93dfda757e1de9c2874eb4a50a7f7 path={namespace}/{kvv2_name}/data/{secret_path} 2024-09-06T09:39:38.521Z [TRACE] proxy.cache.leasecache: restoring capability index: id=e477169eaf91f6a693570a52027f688cedf6ca986b6599ffabcec88bfe3281b0 2024-09-06T09:39:38.521Z [INFO] proxy.cache: loaded memcache from persistent storage 2024-09-06T09:39:38.521Z [DEBUG] proxy.apiproxy: configuring inmem auto-auth sink 2024-09-06T09:39:38.521Z [DEBUG] proxy: would have sent systemd notification (systemd not present): notification=READY=1 2024-09-06T09:39:38.521Z [INFO] proxy.cache.staticsecretcacheupdater: starting static secret cache updater subsystem 2024-09-06T09:39:38.521Z [INFO] proxy.sink.server: starting sink server 2024-09-06T09:39:38.521Z [INFO] proxy.auth.handler: starting auth handler 2024-09-06T09:39:38.521Z [DEBUG] proxy.auth.handler: using preloaded token 2024-09-06T09:39:38.521Z [DEBUG] proxy.auth.handler: lookup-self with preloaded token 2024-09-06T09:39:38.523Z [ERROR] proxy.auth.handler: could not look up token: err="Get \"https://{vault_server}:8200/v1/auth/token/lookup-self\": dial tcp: lookup {vault_server} on 192.168.65.7:53: no such host" backoff=860ms 2024-09-06T09:39:39.388Z [INFO] proxy.auth.handler: authenticating 2024-09-06T09:39:39.392Z [ERROR] proxy.auth.handler: error authenticating: error="Put \"https://{vault_server}:8200/v1/auth/approle/login\": dial tcp: lookup {vault_server} on 192.168.65.7:53: no such host" backoff=860ms 2024-09-06T09:39:40.382Z [INFO] proxy.auth.handler: authenticating ... similar logs
Running the Vault Proxy (version 1.17.5) with Docker: