首页 > 解决方案 > 使用 APPROLE 拉取方法与 Spring Boot 进行 Vault 集成

问题描述

我是避难所的新手。我正在尝试使用 APPROLE 作为身份验证方法将 Vault 与 spring boot 集成。我对 bootstrap.yml 的配置如下:

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>

当我使用此配置运行时。我收到错误

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

我想知道如果我将身份验证方法用作 APPROLE,为什么它会要求令牌。

也可以使用全拉模式进行 APPROLE 身份验证,因为 secret-id 是动态的,不能存储在配置文件中。

标签: springspring-boothashicorp-vault

解决方案


推荐阅读