【发布时间】:2022-10-17 17:37:40
【问题描述】:
鉴于那里的示例仍然太少并且文档相当晦涩,我正试图围绕这个新主题展开思考。
我正在尝试对this repo 进行逆向工程。
我想了解的是我们告知 GCP OIDC 令牌具有具体的属性(即来自特定组织/存储库/分支等)仅被接受为有效。
我注意到 iam 政策是defined,如下所示:
data "google_iam_policy" "wli_user_ghshr" {
binding {
role = "roles/iam.workloadIdentityUser"
members = [
"principalSet://iam.googleapis.com/projects/${data.google_project.project.number}/locations/global/workloadIdentityPools/gh-pool/attribute.full/${var.gh_repo}${var.gh_branch}",
]
}
}
然后我看到身份池提供者也是declared 像这样
resource "google_iam_workload_identity_pool_provider" "provider" {
provider = google-beta
project = var.project_id
workload_identity_pool_id = google_iam_workload_identity_pool.gh_pool.workload_identity_pool_id
workload_identity_pool_provider_id = "gh-provider"
attribute_mapping = {
"google.subject" = "assertion.sub"
"attribute.full" = "assertion.repository+assertion.ref"
}
oidc {
allowed_audiences = ["google-wlif"]
issuer_uri = "https://token.actions.githubusercontent.com"
}
}
我的问题如下:
在 iam 政策声明中执行此行
"principalSet://iam.googleapis.com/projects/${data.google_project.project.number}/locations/global/workloadIdentityPools/gh-pool/attribute.full/${var.gh_repo}${var.gh_branch}",
必须与身份池提供者的attribute_mapping 字段中的属性映射对齐,即
attribute_mapping = {
"google.subject" = "assertion.sub"
"attribute.full" = "assertion.repository+assertion.ref"
}
即是attribute.full
"attribute.full" = "assertion.repository+assertion.ref"
体现在iam政策的principalSet的最后部分如下:
attribute.full/${var.gh_repo}${var.gh_branch}"
?
如果是这样,在attribute_mappinggoogle.subject字段中,assertion.sub的作用是什么? assertion.sub 的值必须是什么具体的?
如果是这样,这是在哪里说明/反映的?
【问题讨论】:
标签: github google-cloud-platform github-actions openid-connect workload-identity