简体   繁体   English

将VaultTemplate与用户名和密码一起使用

[英]Using VaultTemplate with username and password

I'm following a Spring Vault tutorial https://docs.spring.io/spring-vault/docs/current/reference/html/index.html and I have successfully connected the Java program with Vault through token access. 我正在关注Spring Vault教程https://docs.spring.io/spring-vault/docs/current/reference/html/index.html,并且我已经通过令牌访问成功地将Java程序与Vault连接了。 In the picture below, tab number 1. 在下图中,标签号为1。

VaultTemplate vaultTemplate = new VaultTemplate(endpoint, new TokenAuthentication("MySecretToken"));

How do I instantiate the VaultTemplate using user name and password such as when we login through the Vault WebUI in this option (tab number 2)?: 如何使用用户名和密码实例化VaultTemplate,例如当我们通过Vault WebUI在此选项中登录时(选项卡编号2): 在此处输入图片说明

I'm looking at this JavaDoc, but it's not obvious which one to pick: https://docs.spring.io/spring-vault/docs/current/api/index.html?overview-summary.html 我正在查看此JavaDoc,但选择哪一个并不明显: https : //docs.spring.io/spring-vault/docs/current/api/index.html?overview-summary.html

So in another word: How do I connect with Vault, using spring-vault, using username+password instead of token? 换句话说: 如何使用spring-vault,用户名和密码(而不是令牌)与Vault连接? Or at the very least, I need a pointer on how to generate a token with username+password 或者至少,我需要一个有关如何使用用户名和密码生成令牌的指针

As @h3rmanj indicated, Spring Vault does not support username/password authentication because this method is intended for human authentication, not machine-to-machine authentication. 正如@ h3rmanj所指出的那样,Spring Vault不支持用户名/密码身份验证,因为该方法用于人工身份验证,而不是机器对机器身份验证。

Authentication depends on your threat model and how you can/want to address the exploitation of credentials in case of a breach. 身份验证取决于您的威胁模型以及在违反情况下如何/希望如何解决凭据利用问题。 With username/password, you basically need to lock the user of a breached account. 使用用户名/密码,您基本上需要锁定帐户遭到破坏的用户。 This is unfortunate as these accounts tend to be associated with people and you would lock out an operator. 不幸的是,由于这些帐户往往与人相关联,因此您将锁定操作员。

If you use AppRole, you get two factors and you can segregate accounts by application type. 如果使用AppRole,则有两个因素,可以按应用程序类型隔离帐户。 Using tokens gives you the most flexibility if you do not reuse the token across multiple applications . 如果不跨多个应用程序重用令牌,则使用令牌将为您提供最大的灵活性。 Reuse is convenient but also if you encounter a breach, you have to take all applications offline that share the same token. 重用很方便,但是如果遇到违反行为,则必须使共享相同令牌的所有应用程序脱机。 So assigning individual tokens comes with the highest flexibility and the highest amount of operational overhead. 因此,分配单个令牌具有最高的灵活性和最高的运营开销。

Anything in between is a compromise between a reaction to potential breaches and the amount of operational work. 两者之间的任何关系都是对潜在违规行为的反应与操作工作量之间的折衷。

HTH. HTH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM