Vault Integration with Spring boot using APPROLE pull method

Viewed 475

I'm new to the Vault. I'm trying to integrate Vault with spring boot using APPROLE as the authentication method. My configuration of bootstrap.yml is as follows:

spring:
    application:
        name: <application-name>
    cloud:
        vault:
            host: <host-url>
            scheme : https
            port: <port>
            kv-version: 2
            namespace: <namespace-name>
            authentication: APPROLE
            app-role:
                role-id: <role-id>
                role: <role-name>
                app-role-path: <path>

when I'm running using this configuration. I'm getting error

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultTemplate' defined in class path resource [org/springframework/cloud/vault/config/VaultAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.core.VaultTemplate]: Factory method 'vaultTemplate' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultSessionManager' defined in class path resource [org/springframework/cloud/vault/config/VaultAutoConfiguration.class]: Unsatisfied dependency expressed through method 'vaultSessionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientAuthentication' defined in class path resource [org/springframework/cloud/vault/config/VaultAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.authentication.ClientAuthentication]: Factory method 'clientAuthentication' threw exception; nested exception is java.lang.IllegalArgumentException: Token (spring.cloud.vault.token) must not be empty

I'm wondering why it's asking for TOKEN if I used the authentication method as APPROLE.

Also, is it possible to use full pull mode for APPROLE authentication since secret-id is of dynamic nature and can't be stored in the configuration file?

1 Answers

The sample yaml for spring cloud configuration using APPROLE authentication is described below. There are a few things that are misspelled in the config you have mentioned

cloud:
    vault:
      uri: https:<vault-uri>
      authentication: APPROLE
      app-role:
        roleId: <roleId>
        secretId: <secretId>
Related