【问题标题】:Unable to list the LDAP groups in Hashicorp vault, along with the policy attached to it无法列出 Hashicorp 保险库中的 LDAP 组以及附加到它的策略
【发布时间】:2022-01-06 21:08:10
【问题描述】:

我想列出 Hashicorp 保险库中的 LDAP 组,以及在 python 代码中与这些 LDAP 组附加的策略。我能够列出所有 LDAP 组,但无法获取列出策略的命令。

【问题讨论】:

    标签: python-3.x hashicorp-vault vault hashicorp


    【解决方案1】:

    您需要对所有列出的组进行迭代以获取策略信息。类似于在以下 Bash 脚本中完成的操作:

    for g in $(curl --silent --header "X-Vault-Token: VAULT-TOKEN" --request LIST https://VAULT-SERVER/v1/identity/group/name | jq --raw-output .data.keys[])
    do
        echo -n "$g => "
        curl --silent --header "X-Vault-Token: VAULT-TOKEN" --request GET https://VAULT-SERVER/v1/identity/group/name/$g | jq --raw-output .data.policies[]
    done
    

    【讨论】:

      【解决方案2】:

      vault list auth/ldap/groups 将列出每个 LDAP 组名称。但是,正如前面的答案中提到的那样,需要迭代生成的组列表,因为组列表端点仅返回组名称,而不是带有组名称的策略。 vault read auth/ldap/groups/group_name 将返回附加的策略以及其他属性。

      名单:https://www.vaultproject.io/api-docs/auth/ldap#list-ldap-groups

      阅读:https://www.vaultproject.io/api-docs/auth/ldap#read-ldap-group

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-02
        • 2020-01-06
        • 2020-12-16
        • 2016-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多