spring-cloud / spring-cloud-vault

Configuration Integration with HashiCorp Vault
http://cloud.spring.io/spring-cloud-vault/
Apache License 2.0
270 stars 151 forks source link

Add configuration option for X-Vault-Request header #639

Open bt5e opened 2 years ago

bt5e commented 2 years ago

Is your feature request related to a problem? Please describe. When vault agent is configured to enforce X-Vault-Request header requirement, spring vault would error out with

missing 'X-Vault-Request' header; nested exception is org.springframework.web.client.HttpClientErrorException: 412 Precondition Failed: "{"errors":["missing 'X-Vault-Request' header"]}<EOL>"

Describe the solution you'd like A configuration option to add the X-Vault-Request header in all requests to vault.

Describe alternatives you've considered We have turned off the X-Vault-Request header requirement from vault agent side for now.

Additional context Vault documentation: https://www.vaultproject.io/api-docs#the-x-vault-request-header

mp911de commented 2 years ago

You can customize default headers through RestTemplateBuilder:

RestTemplateBuilder builder = RestTemplateBuilder.builder().….defaultHeader("X-Vault-Request", "true");
VaultTemplate template = new VaultTemplate(builder);