【问题标题】:Support for wildcards with Workload Identity Federation通过 Workload Identity Federation 支持通配符
【发布时间】:2021-12-14 01:54:30
【问题描述】:

我目前正在测试这个 Github Action 以使用 Workload Identity Federation 对 gcloud 资源进行身份验证。

我创建了一个带有自定义 repository_ref 属性的 Workload Identity Provider,映射了 Github 存储库和使用 Github Action 的分支:

gcloud iam workload-identity-pools providers create-oidc "my-provider" \
  --project="${PROJECT_ID}" \
  --location="global" \
  --workload-identity-pool="my-pool" \
  --display-name="Demo provider" \
  --attribute-mapping="google.subject=assertion.sub,attribute.repository_owner=assertion.repository_owner,attribute.repository_ref=assertion.repository:assertion.ref" \
  --attribute-condition="attribute.repository_owner=username" \
  --issuer-uri="https://token.actions.githubusercontent.com"

当授予服务帐户模拟权限时,我可以使用此命令确保从 my_repo 存储库的 master 分支触发 Github 操作:

gcloud iam service-accounts add-iam-policy-binding "my-service-account@${PROJECT_ID}.iam.gserviceaccount.com" \
  --role="roles/iam.workloadIdentityUser" \
  --member="principalSet://iam.googleapis.com/${WORKLOAD_IDENTITY_POOL_ID}/attribute.repository_ref/username/my_repo:refs/heads/master"

虽然可以很好地匹配确切的分支名称,但我也想使用它来使用通配符对所有标签创建进行身份验证:

gcloud iam service-accounts add-iam-policy-binding "my-service-account@${PROJECT_ID}.iam.gserviceaccount.com" \
  --role="roles/iam.workloadIdentityUser" \
  --member="principalSet://iam.googleapis.com/${WORKLOAD_IDENTITY_POOL_ID}/attribute.repository_ref/username/my_repo:refs/tags/*"

目前似乎不起作用。有计划支持吗?目前我可以使用其他替代方案吗?

谢谢

【问题讨论】:

  • 这个问题你解决了吗?

标签: google-cloud-iam workload-identity


【解决方案1】:

不支持 AFAIK 通配符。

试试这个:

--member="principalSet://iam.googleapis.com/${WORKLOAD_IDENTITY_POOL_ID}/attribute.repository/username/my_repo"

【讨论】:

    猜你喜欢
    • 2011-01-26
    • 2023-03-06
    • 2014-09-23
    • 2021-10-22
    • 2018-04-21
    • 2021-05-06
    • 2020-10-16
    • 1970-01-01
    • 2022-01-28
    相关资源
    最近更新 更多