[英]Gitlab connection to GCP Workload Identity Federation return invalid_grant
[英]Support for wildcards with Workload Identity Federation
我目前正在測試此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/*"
目前它似乎不起作用。 有計划支持嗎? 有沒有我現在可以使用的替代方案?
謝謝
不支持 AFAIK 通配符。
試試這個:
--member="principalSet://iam.googleapis.com/${WORKLOAD_IDENTITY_POOL_ID}/attribute.repository/username/my_repo"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.