-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add arbitrary headers as ENV (like vault -header) #16663
Comments
I think here is a precedent for VAULT_HEADER (not HEADERS): https://www.vaultproject.io/docs/commands#vault_mfa
"If you need to provide more than one header, please use the vault cli -header flag multiple times." |
Of course I forgot that CF Access takes TWO headers to function:
So it would have to be |
Nevermind this, reply above is what would be needed (now that I got the service tokens actually working). IGNORE THE REST: VAULT_HEADER would be enough in the case of CF Access:
While fetching the token could not be done in CI/CD variables, one could do it in the CI job outside of the script/terraform being run. |
While I still don't think this feature would be a bad idea, I no longer have need for it! I'll try to explain my solution for Vault host's cloudflared config.yaml ingress:
# This is for regular users with browser etc, login via IdP
- hostname: vault.example.com
service: http://127.0.0.1:8081
# This service is a socks proxy, used by cloudflared in CI and locally in CLI
# See: https://developers.cloudflare.com/cloudflare-one/tutorials/kubectl/
- hostname: vault-proxy.example.com
service: tcp://127.0.0.1:8081
originRequest:
proxyType: socks Gitlab CI/CD env variables:
GitLab CI Job: script:
# Create a background job of cloudflared websocket tunnel
- nohup cloudflared access tcp --hostname https://vault-proxy.example.com --url 127.0.0.1:1234 &
# Export proxy info for Vault only
- export VAULT_HTTP_PROXY=socks5://127.0.0.1:1234
# http because traffic goes directly to the origin server through the socks proxy tunnel
- export VAULT_ADDR=http://vault.example.com
# Now vault works, terraform vault provider works...
- vault status |
Seconded this. The problem is not so much that it is not possible to add headers. For example one could do: alias my_vault="vault -header custom-header=value -token $(token-store)"
my_vault some-command -other-flag=other-value It's not show stopping but it's inconvenient to add Is there any specific reason why the command parsing is like that? Would it be possible to submit a change to the way flags are parsed? Come to think of it, I think I can just write a quick wrapper to reorder the flags. |
Hey, For me, I can successfully use the Do you know if the headers are correctly used by the vault-secrets-operator? My helm chart looks like this (just the important part is below):
EDIT: Issue has been opened in VSO github hashicorp/vault-secrets-operator#622 |
Hi all, Awesome that this is possible! I noticed that this code isn't pushed to the 1.17.5 version tags which currently is the latest. |
This should be released in 1.18.0, which should release soon. We generally don't backport features/improvements to older versions except in exceptional cases (only bug fixes/security fixes). |
Hi Violet, Okay, then I'll wait for 1.18.0. Thanks for the fast reply! Edit for future readers: V1.18.0 has been released. |
Is your feature request related to a problem? Please describe.
We got
vault -header
flag from #8754We also have: https://registry.terraform.io/providers/hashicorp/vault/latest/docs#headers
But what we are missing is an ENV for this. I run scripts (and Terraform) that use Vault both locally and in CI. Locally I can talk directly to Vault behind Cloudflare Access without spesifying any extra headers, but in CI I need to specify service account token as a header.
Describe the solution you'd like
It would be super nice to be able to define
VAULT_HEADERS="foo=bar bar=baz"
in CI/CD variables. This way I would not need to touch my scripts in any way.I think this would be equivalent to
VAULT_CLIENT_CERT
andVAULT_CLIENT_KEY
, which I used previously with Cloudflare provided mTLS to protect my Vault.The ONLY thing is, since
-header
and TF provider'sheader {}
can be spesified multiple times, and ENV's cannot be, is a whitespace the correct separator for headers in the env? I can see this being quite the problem.The text was updated successfully, but these errors were encountered: