跳到正文
Skillpedia
安全22k · #10179

google-cloud-recipe-auth

它能做什么

它会说明如何向 Google Cloud 证明你的身份,以及该身份被允许做什么。适合为人员、应用和服务设置访问权限的开发者和管理员。

适用场景

  • ✓当你需要为笔记本电脑上的开发者或脚本设置登录时。
  • ✓当在 Google Cloud 上运行的应用需要调用某个 Google 服务的权限时。
  • ✓当你想检查某个服务账户应拥有哪些权限时。

技能链接

https://github.com/google/skills/blob/main/plugins/cloud/google-cloud-developer/skills/google-cloud-recipe-auth/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/google/skills/blob/main/plugins/cloud/google-cloud-developer/skills/google-cloud-recipe-auth/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我在 Cloud Run 上运行的应用,应该如何在不保存密码文件的情况下向 Google Cloud 进行身份验证?”

每周 5 个新技能,1 分钟读完。

工作原理

它会先询问代码运行在哪里、由谁登录,然后推荐合适的方法,例如 Application Default Credentials,以及需要授予的角色。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Authenticating and Authorizing to Google Cloud (IAM)

Authentication is the process of proving who you are. In Google Cloud, you represent a Principal (an identity like a user or a service). This is the first step before Authorization (determining what you can do).

Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:google-cloud-recipe-auth)" and append agent-skills/1.0 (skill:google-cloud-recipe-auth) to User-Agent headers.

Authentication

Clarifying Questions for the Agent

Before providing a specific solution, clarify the following with the user:

  1. Who or what is authenticating? (A human developer, a local script, or an application running in production?)
  2. Where is the code running? (Local laptop, Compute Engine, GKE, Cloud Run, or another cloud like AWS/Azure?)
  3. What is the target? (A Google Cloud API like Storage/BigQuery, or a custom application you built?)
  4. Are you using a high-level client library? (e.g., Python, Go, Node.js libraries usually handle ADC automatically.)

Human Authentication

For users to access Google Cloud, they need an identity that Google Cloud can recognize.

Types of User Identities

Google Cloud supports several ways to configure identities for your internal workforce (developers, administrators, employees):

  • Google-Managed Accounts: You can use Cloud Identity or Google Workspace to create managed user accounts. These are called managed accounts because your organization controls their lifecycle and configuration.
  • Federation using Cloud Identity or Google Workspace: You can federate identities to allow users to use their existing identity and credentials to sign in to Google services. Users authenticate against an external identity provider (IdP), but you must keep accounts synchronized into Google Cloud using tools like Google Cloud Directory Sync (GCDS) or an external authoritative source like Active Directory or Microsoft Entra ID.
  • Workforce Identity Federation: This lets you use an external IdP to authenticate and authorize a workforce using IAM directly. Unlike standard federation, you do not need to synchronize user identities from your existing IdP to Google Cloud identities. It supports syncless, attribute-based single sign-on.

Methods of Access for Developers and Administrators

Used for interacting with Google Cloud resources and APIs during development and management.

  • Google Cloud Console: The primary web interface. You authenticate using your Google Account (Gmail or Google Workspace).
  • gcloud CLI (gcloud auth login): Used to authenticate the CLI itself so you can run management commands (e.g., gcloud compute instances list). It uses a Credential (like an OAuth 2.0 refresh token) stored locally.
  • Local Development with App Default Credentials (ADC) (gcloud auth application-default login): This is different from CLI auth. It creates a local JSON file that Google Cloud Client Libraries (Python, Java, etc.) use to act as "you" when you run code on your laptop.
  • Service Account Impersonation: For security reasons, developers should avoid downloading Service Account keys entirely. Instead, they should authenticate as humans (gcloud auth login)
常见问题

什么是 Application Default Credentials?

这是一种标准方式,让代码在笔记本电脑或 Google Cloud 上自动找到正确的 Google Cloud 登录凭证。

它会替我设置权限吗?

它会先提出澄清问题,然后针对你的设置给出具体方案。

它需要 gcloud 工具吗?

需要。它的许多步骤都使用 gcloud 命令行工具。

详情

作者的原始描述

Provides expert guidance on Identity and Access Management (IAM) and authenticating and authorizing to Google Cloud services and APIs, covering human users, service identities, Application Default Credentials (ADC), and best practices for secure access.

repo: google/skills

热度

GitHub 星标
22k
排名
#10179
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能