Vault中使用AppRole

Database and Ruby, Python, History


很久之前就使用过了 Vault,最近尝试使用 Vault 保存一些配置和 Token,所以使用 AppRole 这种认证方式。

首先创建一个airflow的 policy,指定拥有这个 policy 的 token 可以有哪些权限。

path "kv/*" {
    capabilities = ["create", "read", "update", "delete", "list"]
}

然后创建一个airflow的 approle,绑定上面的airflow policy。AppRole 会有一个role-id和多个secret-id

vault write auth/approle/role/airflow token_policies="airflow" secret_id_ttl=8760h token_ttl=1h token_max_ttl=4h secret_id_num_uses=0

查看创建的airflowrole-id

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

创建一个新的secret-id。注意,这个secret-id只会显示一次,如果忘记了就需要创建新的。

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

查看所有的secret-id,出于安全性,这里只会显示secret-id-accessor,而不会明文显示secret-id

vault list auth/approle/role/airflow/secret-id

更多

使用 unwrap 获取secret-id 可以显示 CIDR 访问 Vault 获取 token 可以定期轮换secret-id