codecamp

Spring Cloud Vault快速入门

先决条件

要开始使用Vault和本指南,您需要一个类似* NIX的操作系统,该操作系统提供:

  • wgetopensslunzip
  • 至少Java 7和正确配置的JAVA_HOME环境变量

安装Vault

$ src/test/bash/install_vault.sh

为Vault创建SSL证书

$ src/test/bash/create_certificates.sh

create_certificates.shwork/ca和JKS信任库work/keystore.jks中创建证书。如果要使用此快速入门指南运行Spring Cloud Vault,则需要将信任库的spring.cloud.vault.ssl.trust-store属性配置为file:work/keystore.jks

启动Vault服务器

$ src/test/bash/local_run_vault.sh

Vault开始使用inmem存储和https0.0.0.0:8200上侦听。Vault被密封并且在启动时未初始化。

 如果要运行测试,请保留Vault未初始化。测试将初始化Vault并创建根令牌00000000-0000-0000-0000-000000000000

如果要对应用程序使用Vault或尝试使用它,则需要首先对其进行初始化。

$ export VAULT_ADDR="https://localhost:8200"
$ export VAULT_SKIP_VERIFY=true # Don't do this for production
$ vault init

您应该看到类似以下内容:

Key 1: 7149c6a2e16b8833f6eb1e76df03e47f6113a3288b3093faf5033d44f0e70fe701
Key 2: 901c534c7988c18c20435a85213c683bdcf0efcd82e38e2893779f152978c18c02
Key 3: 03ff3948575b1165a20c20ee7c3e6edf04f4cdbe0e82dbff5be49c63f98bc03a03
Key 4: 216ae5cc3ddaf93ceb8e1d15bb9fc3176653f5b738f5f3d1ee00cd7dccbe926e04
Key 5: b2898fc8130929d569c1677ee69dc5f3be57d7c4b494a6062693ce0b1c4d93d805
Initial Root Token: 19aefa97-cccc-bbbb-aaaa-225940e63d76

Vault initialized with 5 keys and a key threshold of 3. Please
securely distribute the above keys. When the Vault is re-sealed,
restarted, or stopped, you must provide at least 3 of these keys
to unseal it again.

Vault does not store the master key. Without at least 3 keys,
your Vault will remain permanently sealed.

Vault将初始化并返回一组启封密钥和根令牌。选择3个键并解开Vault。将Vault令牌存储在VAULT_TOKEN环境变量中。

$ vault unseal (Key 1)
$ vault unseal (Key 2)
$ vault unseal (Key 3)
$ export VAULT_TOKEN=(Root token)
# Required to run Spring Cloud Vault tests after manual initialization
$ vault token-create -id="00000000-0000-0000-0000-000000000000" -policy="root"

Spring Cloud Vault访问不同的资源。默认情况下,启用秘密后端,该后端通过JSON端点访问秘密配置设置。

HTTP服务具有以下形式的资源:

/secret/{application}/{profile}
/secret/{application}
/secret/{defaultContext}/{profile}
/secret/{defaultContext}

如果将“应用程序”作为spring.application.name插入SpringApplication中(即常规Spring Boot应用程序中通常是“应用程序”),则“配置文件”是有效的配置文件(或逗号分隔的列表)属性)。从Vault中检索到的Properties将按原样使用,而无需进一步添加属性名称的前缀。

Spring Cloud 链接
Spring Cloud 身份验证
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

三、Spring Cloud Netflix

SpringCloud Hystrix超时和Ribbon客户

SpringCloud 重试失败的请求

五、Spring Cloud Stream

六、SpringCloud Binder实现

SpringCloud 重试RabbitMQ Binder

SpringCloud Dead-Letter队列处理

八、Spring Cloud Sleuth

SpringCloud 当前Span

十二、Spring Cloud for Cloud Foundry

十三、Spring Cloud Contract

Spring Cloud Contract验证程序设置

SrpingCloud Gradle项目

十五、Spring Cloud网关

Spring Cloud 配置路由谓词工厂和网关过滤工厂

Spring Cloud TLS / SSL

Spring Cloud网关配置

SpringCloud 故障排除

十八、Spring Cloud GCP

Spring Cloud GCP Spring资源

Spring Cloud Spring JDBC

Spring Cloud Redis的Cloud Memorystore

Spring Cloud 云身份识别代理(IAP)身份验证

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }