如何在 Google Cloud Platform 中获取用户管理服务帐户的 Public 密钥

How do I get Public Key of a User Managed Service account in Google Cloud Platform

我正在使用 Google Cloud Scheduler 调用外部应用程序。 Google Cloud Scheduler 使用 OIDC 身份验证并使用服务帐户。我只能从 Google 服务帐户 UI 控制台页面获取服务帐户的私钥。我如何获取该用户托管服务帐户的 public?

我通过在此处粘贴 Bearer 令牌找到了此服务帐户的 public 密钥:https://jwt.io/

但是,这是获取服务帐户 public 密钥的唯一方法吗?还有其他方法吗? (如图书馆等)?有什么办法可以从 Google utils 或 gcloud 或 Google console 得到这个吗?

其中一个网站提到 "The public key can be widely distributed, so every consumer of the token can verify its integrity."。那么,这个 Google 服务帐户的 public 密钥分发到哪里了?是否有一个 server/place 存储所有 Google 服务帐户 public 密钥?

此外,还有一个选项可以将 public 密钥作为 jwt 令牌的一部分嵌入。如果我从 google 云调度程序获得一个不记名令牌,我怎么知道它是否嵌入了 public 密钥?还是分发 public 密钥?

在此先感谢您的支持!

此致

P.S:我通读了这些但不是很有帮助:

1. 2. https://www.pingidentity.com/fr/company/blog/posts/2019/the-hard-parts-of-jwt-security-nobody-talks-about.html

根据官方文档:

Creating and managing service account keys

Google ensures that all public keys for all service accounts are publicly accessible by anyone and available to verify signatures that are created with the private key. The public key is publicly accessible at the following URLs:

1.x.509 certificate: https://www.googleapis.com/service_accounts/v1/metadata/x509/[SA-NAME]@[PROJECT-ID].iam.gserviceaccount.com

2.JSON web key (JWK): https://www.googleapis.com/service_accounts/v1/jwk/[SA-NAME]@[PROJECT-ID].iam.gserviceaccount.com

3.Raw endpoint: https://www.googleapis.com/service_accounts/v1/metadata/raw/[SA-NAME]@[PROJECT-ID].iam.gserviceaccount.com

我使用 curl 访问 URL:

  curl -i  https://www.googleapis.com/service_accounts/v1/jwk/[SA-NAME]@[PROJECT-ID].iam.gserviceaccount.com
{
"keys": [
  {
    "e": "xxxx",
    "kty": "xxx",
    "alg": "xxxx",
    "n": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "use": "xxx",
    "kid": "xxxxxxxxxxxxxxxx"
  }
]
}

或访问原始端点:

     curl -i https://www.googleapis.com/service_accounts/v1/metadata/raw/[SA-NAME]@[PROJECT-ID].iam.gserviceaccount.com
   {
 "keyvalues": [
   {
     "exponent": "xxx",
     "keyid": "xxxxxxxxxxx",
     "modulus": "xxxxxxxxxxx",
     "algorithm": "xxx"
   }
 ]
}