Vault:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
 
(未显示同一用户的25个中间版本)
第4行: 第4行:


Vault可以拿來存放各類credential資料,像是Key或是Password,這個方法比Twelve-Factor App methodology所提到的方法(利用環境變數)安全許多。
Vault可以拿來存放各類credential資料,像是Key或是Password,這個方法比Twelve-Factor App methodology所提到的方法(利用環境變數)安全許多。
== 安裝 ==
{{Main|Vault/Install}}
== AppRole<ref>{{Cite web |url=https://learn.hashicorp.com/vault/identity-access-management/approle |title=AppRole Pull Authentication |language=en |accessdate=2020-07-29}}</ref> ==
以下的指令可以透過Vault的CLI操作,會需要設定對應的Endpoint(環境變數<code>VAULT_ADDR</code>)與token(環境變數<code>VAULT_TOKEN</code>)。
=== 啟用 ===
先啟用AppRole:
<syntaxhighlight lang="bash">
vault auth enable approle
</syntaxhighlight>
=== TTL設定 ===
你可能會想要改掉預設的TTL,目前的預設是30天(768h),這邊設定為100年:
<syntaxhighlight lang="bash">
vault read sys/auth/approle/tune
vault write sys/auth/approle/tune max_lease_ttl=876000h
vault write sys/auth/approle/tune default_lease_ttl=876000h
vault read sys/auth/approle/tune
</syntaxhighlight>
=== 建立 ===
先產生AppRole:
<syntaxhighlight lang="bash">
vault write auth/approle/role/example_role token_policies="example_policy1,example_policy2"
</syntaxhighlight>
接下來是讀取<code>role-id</code>:
<syntaxhighlight lang="bash">
vault read auth/approle/role/example_role/role-id
</syntaxhighlight>
產生對應的<code>secret-id</code>:
<syntaxhighlight lang="bash">
vault write -f auth/approle/role/example_role/secret-id
</syntaxhighlight>
其中輸出的<code>secret_id</code>就是我們要的,而<code>secret_id_accessor</code>則可以拿來renew用(但比較少用到)。
=== 使用 ===
這邊使用[[HTTPie]]產生JSON request:
<syntaxhighlight lang="bash">
http https://vault.example.com/v1/auth/approle/login role_id=x secret_id=y
</syntaxhighlight>
回傳的<code>client_token</code>就可以拿來使用。


== 相關連結 ==
== 相關連結 ==
第9行: 第68行:
* [[Vault/Install]]
* [[Vault/Install]]


== 參考文獻 ==
{{Reflist|2}}
== 外部連結 ==
* {{Official|https://www.vaultproject.io/}} {{en}}
[[Category:Vault|*]]
[[Category:軟體]]
[[Category:軟體]]

2021年6月30日 (三) 07:44的最新版本

Vault是一套由HashiCorp开发的密码管理软件。

概要

Vault可以拿来存放各类credential资料,像是Key或是Password,这个方法比Twelve-Factor App methodology所提到的方法(利用环境变数)安全许多。

安装

AppRole[1]

以下的指令可以透过Vault的CLI操作,会需要设定对应的Endpoint(环境变数VAULT_ADDR)与token(环境变数VAULT_TOKEN)。

启用

先启用AppRole:

vault auth enable approle

TTL设定

你可能会想要改掉预设的TTL,目前的预设是30天(768h),这边设定为100年:

vault read sys/auth/approle/tune
vault write sys/auth/approle/tune max_lease_ttl=876000h
vault write sys/auth/approle/tune default_lease_ttl=876000h
vault read sys/auth/approle/tune

建立

先产生AppRole:

vault write auth/approle/role/example_role token_policies="example_policy1,example_policy2"

接下来是读取role-id

vault read auth/approle/role/example_role/role-id

产生对应的secret-id

vault write -f auth/approle/role/example_role/secret-id

其中输出的secret_id就是我们要的,而secret_id_accessor则可以拿来renew用(但比较少用到)。

使用

这边使用HTTPie产生JSON request:

http https://vault.example.com/v1/auth/approle/login role_id=x secret_id=y

回传的client_token就可以拿来使用。

相关连结

参考文献

  1. AppRole Pull Authentication. [2020-07-29] (English). 

外部链接