首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Spring中存储令牌

在Spring中存储令牌
EN

Stack Overflow用户
提问于 2017-12-07 05:34:15
回答 1查看 4.3K关注 0票数 2

我使用两个配置服务器运行微服务:

  • (带有git后端)
  • 春云库

我将Vault令牌存储在服务器中。在启动微服务时,我希望它:

  1. 检索存储在Spring中的配置,包括Vault令牌。
  2. 使用Vault令牌连接到Spring,然后检索存储在Spring中的配置。

bootstrap.properties:

代码语言:javascript
复制
spring.application.name=my-app
spring.cloud.config.uri=http://localhost:8888

Spring服务器:

代码语言:javascript
复制
spring.cloud.vault.token=19aefa97-cccc-bbbb-aaaa-225940e63d76

但是,我遇到了一个例外,即spring.cloud.vault.token必须存在。

代码语言:javascript
复制
Caused by: java.lang.IllegalArgumentException: Token (spring.cloud.vault.token) must not be empty
    at org.springframework.util.Assert.hasText(Assert.java:181)
    at org.springframework.cloud.vault.config.VaultBootstrapConfiguration.clientAuthentication(VaultBootstrapConfiguration.java:270)
    at org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$473cc7b3.CGLIB$clientAuthentication$7(<generated>)
    at org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$473cc7b3$$FastClassBySpringCGLIB$$5f991c47.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
    at org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$473cc7b3.clientAuthentication(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 88 common frames omitted

问题:

  1. 在Spring中存储Vault令牌对于微服务以后访问Spring是一个有效的用例吗?
  2. 如果是,是否需要设置检索属性的顺序?即为Spring设置spring.cloud.vault.config.order。有任何等效的参数吗?
EN

回答 1

Stack Overflow用户

发布于 2018-02-27 16:36:18

  1. 看起来这里的Vault令牌使用是无效的。根据文档,Spring客户端应该为服务器提供一个令牌,以便从Vault - 春云交汇处检索值。因此,在Config Server中,您只需为git repos和Vault服务器提供配置,仅此而已。它并不是像从Git repos中那样,从Vault获得所有的信任。它将通过来自配置客户端的请求检索敏感属性,该客户端将具有正确的Vault令牌。
  2. 是的,这里有秩序财产, spring:概要文件: active: pass,git: config: server: server:1 git : order: 2 uri:https://some-git-repo.com/ username: user password: pass

我使用了来自这个StackOverflow问题的配置,它帮助了我并且工作得很好。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47688262

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档