0

我想自定义spring-cloud-starter-vault-config使用 Thycotic 作为后端之一。

直到我没有试过

  1. AbstractVaultConfiguration如下所示配置 a并尝试禁用VaultAutoConfiguration. 下面如果我的代码但它不起作用
@Configuration
public class ThycoticConfig extends AbstractVaultConfiguration {
    @Value("${secret_server.api_root_url}")
    private URI vaultEndpoint;
    @Override
    public VaultEndpoint vaultEndpoint() {
        return VaultEndpoint.from(vaultEndpoint);
    }

    @Component
    public static class ThycoticClientAuthentication implements ClientAuthentication {
        @Value("${secret_server.oauth2.token_url}")
        private String oauth2TokenUrl;

        @Override
        public VaultToken login() throws VaultException {
            final MultiValueMap<String, String> request = new LinkedMultiValueMap();
            request.add("username", "abc");
            request.add("password", "xyz");
            request.add("grant_type", "password");
            final JsonNode response = new RestTemplate().postForObject(this.oauth2TokenUrl, request, JsonNode.class);
            final VaultToken token = VaultToken.of(response.get("access_token").asText());
            return token;
        }
    }

    @Override
    public ClientAuthentication clientAuthentication() {
        return new ThycoticClientAuthentication();
    }
}
  1. 阅读SecretBackendMetadataFactoryVaultSecretBackendDescriptor但无法配置它(可能我在这里切线)。

我不确定如何将 Thycotic vault 与spring-cloud-starter-vault-config.

请帮忙!

4

0 回答 0