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

Wor*_*ork 3 encryption-asymmetric public-key-encryption jwt google-cloud-platform openid-connect

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

我通过在此处粘贴不记名令牌找到了该服务帐户的公钥: https: //jwt.io/

但是,这是获取服务帐户公钥的唯一方法吗?还有其他方法可以得到这个吗?(如图书馆等)?有什么方法可以从 Google utils 或 gcloud 或 Google 控制台获取此信息吗?

其中一个网站提到“公钥可以广泛分发,因此令牌的每个消费者都可以验证其完整性。” 那么,这个Google服务帐户的公钥分发到哪里了?是否有存储所有 Google 服务帐户公钥的服务器/位置?

此外,还可以选择将公钥作为 jwt 令牌的一部分嵌入。如果我从谷歌云调度程序获得不记名令牌,我如何知道它是否嵌入了公钥?或者它是分布式公钥?

预先感谢您的支持!

问候

PS:我读过这些但不是很有帮助:

1.获取 Google 云服务帐户的开发人员密钥 2. https://www.pingidentity.com/fr/company/blog/posts/2019/the-hard-parts-of-jwt-security-nobody-talks-about。 html

mar*_*doi 10

根据官方文档:

创建和管理服务帐户密钥

Google 确保所有服务帐户的所有公钥可供任何人公开访问,并可用于验证使用私钥创建的签名。公钥可通过以下 URL 公开访问:

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

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

3.原始端点: 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
Run Code Online (Sandbox Code Playgroud)
{
"keys": [
  {
    "e": "xxxx",
    "kty": "xxx",
    "alg": "xxxx",
    "n": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "use": "xxx",
    "kid": "xxxxxxxxxxxxxxxx"
  }
]
}

Run Code Online (Sandbox Code Playgroud)

或者访问原始端点:

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