Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

gcp-auth

БесплатноБез исполняемых скриптовНе проверен

Configure authentication and authorization for Google Cloud — Application Default Credentials (ADC), service account impersonation, Workload Identity…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

GCP Authentication & Authorization

Overview

Authentication answers "who are you?" — authorization (IAM) answers "what can you do?" Google Cloud uses three concepts together: Principals (user accounts, service accounts, federated identities), short-lived tokens issued by metadata servers or the Service Account Credentials API, and IAM Allow Policies that bind principals to predefined or custom roles on resources.

The right pattern depends on where the code runs and who is calling.

Instructions

Decision Matrix

Scenario Use
Local development, calling Google APIs gcloud auth application-default login (ADC)
Local dev, but you need to act as a service account Service account impersonation (NOT keys)
Code on Compute Engine / Cloud Run / Cloud Functions Attached service account + metadata server
Code on GKE Workload Identity Federation for GKE (direct principal:// binding)
Code on AWS / Azure / on-prem Workload Identity Federation (with external IdP)
Calling a private Cloud Run / Cloud Functions service OIDC ID token in Authorization: Bearer
Public / quota-limited APIs (Maps, Vertex AI Express) API key with restrictions

If a downloadable service account key (JSON) appears in the answer for any of these, the answer is wrong.

Local Development with Application Default Credentials

# One-time setup: log in as your human account
gcloud auth login

# Create local ADC (this is what client libraries use)
gcloud auth application-default login

# Set the project for downstream commands
gcloud config set project my-project
gcloud auth application-default set-quota-project my-project
# No credentials in code — ADC is picked up automatically
from google.cloud import storage

client = storage.Client()  # uses ~/.config/gcloud/application_default_credentials.json
for blob in client.list_blobs("my-bucket"):
    print(blob.name)

ADC search order:

  1. GOOGLE_APPLICATION_CREDENTIALS env var (path to a credential config or key JSON file)
  2. The file from gcloud auth application-default login (cloud-platform scope unless you pass --scopes)
  3. Attached service account on the runtime (GCE, Cloud Run, GKE, etc.)

Service Account Impersonation (Local Dev, Production-Like)

Never download service account keys for local testing. Impersonate instead.

# Grant your user the Token Creator role on the target service account
gcloud iam service-accounts add-iam-policy-binding \
  [email protected] \
  --member="user:[email protected]" \
  --role="roles/iam.serviceAccountTokenCreator"

# Use impersonation for one command
gcloud storage buckets list \
  --impersonate-service-account=prod-deploy@my-project.iam.gserviceaccount.com

# Or set ADC to use impersonation persistently
gcloud auth application-default login \
  --impersonate-service-account=prod-deploy@my-project.iam.gserviceaccount.com

Production: Attached Service Accounts

# Cloud Run
gcloud run deploy api \
  --image=us-central1-docker.pkg.dev/my-project/repo/api:v1 \
  --region=us-central1 \
  [email protected]

# Compute Engine
gcloud compute instances create web-1 \
  --zone=us-central1-a \
  [email protected] \
  --scopes=cloud-platform

# Cloud Run functions (formerly Cloud Functions 2nd gen)
gcloud functions deploy process-events \
  --gen2 --region=us-central1 \
  --runtime=python313 \
  --trigger-topic=events \
  --service-account=events-runtime@my-project.iam.gserviceaccount.com

The runtime fetches a short-lived OAuth token from the local metadata server — application code calls google.auth.default() and just works.

Workload Identity Federation for GKE

Autopilot clusters have it enabled already. On Standard clusters enable it on the cluster and on node pools:

gcloud container clusters update prod-cluster \
  --region=us-central1 \
  --workload-pool=my-project.svc.id.goog

gcloud container node-pools update default-pool \
  --cluster=prod-cluster --region=us-central1 \
  --workload-metadata=GKE_METADATA

Current best practice is to grant roles directly to the Kubernetes ServiceAccount principal, with no Google service account in between:

gcloud projects add-iam-policy-binding my-project \
  --role="roles/storage.objectViewer" \
  --member="principal://iam.googleapis.com/projects/123456789012/locations/global/workloadIdentityPools/my-project.svc.id.goog/subject/ns/default/sa/orders-api"

If a Google API does not yet support principal identifiers, fall back to the older annotation method: bind a Google service account and annotate the Kubernetes ServiceAccount.

gcloud iam service-accounts add-iam-policy-binding \
  [email protected] \
  --role="roles/iam.workloadIdentityUser" \
  --member="serviceAccount:my-project.s
Полный SKILL.md на GitHub

Установить gcp-auth в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл gcp-auth?

Configure authentication and authorization for Google Cloud — Application Default Credentials (ADC), service account impersonation, Workload Identity Federation for GKE and external clouds, and OIDC ID tokens for service-to- service auth. Use when setting up local dev access, deploying to Cloud Run / Cloud Functions / GKE, or calling private Google Cloud APIs.

Как установить скилл gcp-auth?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл gcp-auth запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить gcp-auth с