spring-cloud / spring-cloud-vault

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

Add spring.config.import example #567

Closed Monax111 closed 3 years ago

Monax111 commented 3 years ago

I want use new spring boot 2.4.2 I know about big changes in config processing. I try to change my config, but failed. My old config in file bootstrap.yml is like this. It's work.

spring:
  cloud:
     vault:
      scheme: https
      host: vault-host.ru
      port: 443
      generic:
        backend: bpm/dev
      authentication: approle
      app-role:
        secret-id: 3211233123-13213-123123-7e11-123123123123
        role-id: 321-123231-351231239c-123123-123131231231
      enabled: true

Now it move it in application.yml and it not work

spring:
  cloud:
    vault:
      scheme: https
      host: vault-host.ru
      port: 443
      authentication: approle
      app-role:
        secret-id: 3211233123-13213-123123-7e11-123123123123
        role-id: 321-123231-351231239c-123123-123131231231
      enabled: true
      application-name: dependency-manager-example-multi-module-one
  config:
    import: vault://bpm/dev/ #from generic.backend: bpm/dev right?

now i see

HttpClientErrorException$Forbidden: 403 Forbidden: [{"errors":["1 error occurred:\n\t* permission denied\n\n"]}

I start debug VaultTemplate.doRead() and this is a list of the path that i saw.

all path is wrong. i expect two path:

Monax111 commented 3 years ago

after 3 hours debug i see, property read from bootstrap.yml which i dont remove. I cange it like this

spring:
  application:
    name: dependency-manager-example-multi-module-one
  cloud:
    vault:
      scheme: https
      host: vault-host.ru
      port: 443
      kv:
        backend: bpm/dev
        enabled: true
      authentication: approle
      app-role:
        secret-id: 3211233123-13213-123123-7e11-123123123123
        role-id: 321-123231-351231239c-123123-123131231231
      enabled: true

And it work! I do not understand anything! but it works !!! could anyone please explain how it works? it's private project, but i can give gradle build scan https://scans.gradle.com/s/watftuiqs4cma

mp911de commented 3 years ago

Examples live at https://github.com/mp911de/spring-cloud-vault-config-samples. We should upgrade to Spring Boot 2.4 there.

Monax111 commented 3 years ago

In ReadMe this project your team recommended use application.yml with configure

spring.cloud.vault:
    host: localhost
    port: 8200
    scheme: https
    uri: https://localhost:8200
    connection-timeout: 5000
    read-timeout: 15000
    config:
spring.config.import: vault://

In your project https://github.com/mp911de/spring-cloud-vault-config-samples i don't found any file this name "application.yml" or "application.properties" or include text like "spring.config.import" Сan you point more specifically to an demo application customized according to your recommendations?

Monax111 commented 3 years ago

image