spring-cloud / spring-cloud-vault

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

Spring cloud vault config ask for Token inspite of given authentication Method as APPROLE #624

Closed anuragsrivastava-tomtom closed 2 years ago

anuragsrivastava-tomtom commented 2 years ago

I'm using spring boot version 2.4.4 and spring.cloud.starter-vault-config=3.0.0 When I define authentication method as APPROLE in bootstrap.properties by enabling legacy bootstrap configuration property spring.cloud.bootstrap.enabled=true. It still ask me for vault token.

Error Log : Vault token must not be empty

this is my bootstrap.properties configuration.

spring.cloud.vault.host=<url> spring.cloud.vault.port= <port> spring.cloud.vault.scheme= https spring.cloud.vault.kv-version= 2 spring.cloud.vault.namespace= <namespace_name> spring.cloud.vault.authentication= APPROLE spring.cloud.vault.app-role.role-id= <role_id> spring.cloud.vault.app-role.role=<role> spring.cloud.vault.authentication.app-role.app-role-path= <role_path> spring.cloud.vault.app-role.secret-id=<secret_id> spring.cloud.vault.generic.enabled = true spring.config.import = vault://<mount_path_at_vault> `

Also,

I knew that bootstrap.properties is now legacy affair then how to map secrets read from vault to datasource property. During experiment I found that datasource bean get's created before vault bean hence couldn't map the credentails that are fetched from the vault.

mp911de commented 2 years ago

spring.config.import and spring.cloud.bootstrap.enabled=true cannot be used together. You must use either one or the other.