api-gateway-backend-security-and-rate-limiting
Was er macht
Dieser Skill hilft einem KI-Agenten, eine API abzusichern, die hinter dem Google Cloud API Gateway läuft. Gedacht ist das für Entwickler, die steuern wollen, wer ihre API aufrufen darf und wie oft.
Wann du ihn nutzt
- ✓Wenn du API-Schlüssel oder Anmeldetokens verlangen willst, bevor Menschen deine API auf Google Cloud aufrufen können.
- ✓Wenn du ein Cloud-Run-Backend schützen musst, sodass nur das API-Gateway es erreichen kann.
- ✓Wenn du Anfragelimits pro Projekt für einen API-Gateway-Dienst festlegen willst.
Link zum Skill
https://github.com/google/skills/blob/main/skills/cloud/api-gateway-backend-security-and-rate-limiting/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Schütze meine API auf Google Cloud, sodass sie nur von angemeldeten Nutzern mit gültigem Schlüssel aufgerufen werden kann, und begrenze, wie viele Anfragen sie machen dürfen.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Er aktualisiert die API-Definitionsdatei, um Anmeldeprüfungen, ein Gateway-Dienstkonto für das Backend und Limits pro Projekt hinzuzufügen. Außerdem führt er Prüfungen der Einstellungen aus.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
API Gateway Backend Security and Rate Limiting
This skill configures client authentication, gateway-to-backend authentication, and per-project rate limits (quotas) for Google Cloud API Gateway across OpenAPI 2.0 (swagger: "2.0") and OpenAPI 3.0.x (openapi: 3.0.4), including gateways with Model Context Protocol (MCP) enabled (Public Preview).
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:api-gateway-backend-security-and-rate-limiting)"
and append agent-skills/1.0 (skill:api-gateway-backend-security-and-rate-limiting) to User-Agent headers.
Prerequisites
- Install the Google Cloud CLI and Python 3.10+ YAML parser:
- Install or update the Google Cloud SDK.
- Install
PyYAMLfor the quota metric validation script:pip install "PyYAML>=6.0,<7.0"
- Authenticate your environment:
- Local CLI session:
gcloud auth login - Application Default Credentials (SDKs):
gcloud auth application-default login - Service account key file (if required by CI): set
GOOGLE_APPLICATION_CREDENTIALS={key_file_path}
- Local CLI session:
- Select or create a project, verify billing, and pick a supported gateway location:
- Select an existing project (
gcloud config set project {project_id}) or create one (gcloud projects create {project_id}as an escape hatch). - Verify that an active billing account is linked to
{project_id}(required even when staying within the API Gateway pricing free tier). - Use
us-central1as the default--locationfor API Gateway commands. For the other supported regions, see API Gateway deployment model.
- Select an existing project (
- Enable required Google Cloud APIs:
API Gateway does not need the Cloud Run API. If the backend runs on Cloud Run, that API is already enabled in the backend's project.gcloud services enable \ apigateway.googleapis.com \ servicemanagement.googleapis.com \ servicecontrol.googleapis.com \ iam.googleapis.com \ apikeys.googleapis.com \ --project={project_id} - Verify required IAM roles:
- To manage API Gateway resources and enable services:
roles/apigateway.adminandroles/serviceusage.serviceUsageAdmin - To create the gateway service account and attach it to an API config:
roles/iam.serviceAccountAdminandroles/iam.serviceAccountUser - To manage API keys in consumer projects:
roles/serviceusage.apiKeysAdmin - For the gateway service account to invoke the backend:
roles/run.invoker(Cloud Run or 2nd gen functions) orroles/cloudfunctions.invoker(1st gen functions)
- To manage API Gateway resources and enable services:
Decision Matrix: Client Authentication, Backend Security, and Quotas
Select the layer that matches the security requirement:
| Goal | Mechanism to Configure | Key Constraint | Detailed Reference |
|---|---|---|---|
| Identify the calling consumer project for quotas and billing | API key (x-api-key header convention; key query parameter escape hatch) |
NEVER rely on an API key alone to authenticate end-user identity. Rationale: API keys identify a Google Cloud project rather than a user, and clients can extract them. | Client Authentication |
| Authenticate end users or calling services | JWT (oauth2 scheme with x-google-issuer / x-google-jwks_uri in OAS 2.0, or x-google-auth in OAS 3.x) |
Operation-level security overrides root security. Include api_key: [] and the JWT scheme in the same security requirement object when an endpoint needs both user identity and quotas. |
Client Authentication |
| Block direct calls to the backend service | Dedicated gateway service account (--backend-auth-service-account) + roles/run.invoker + backend --no-allow-unauthenticated |
Roll out the gateway config with --backend-auth-service-account BEFORE setting --no-allow-unauthenticated on a live backend to avoid 403 downtime. |
Backend Security |
| Rate limit requests per consumer project (`1/mi |
Häufige Fragen
Welche API-Dateiformate unterstützt er?
Er unterstützt OpenAPI-2.0- und OpenAPI-3.0.x-Dateien, auch bei Gateways mit eingeschaltetem MCP.
Kann mein Backend erkennen, wer es aufruft?
Ja. Das Gateway gibt die Ansprüche des angemeldeten Nutzers in einem Header weiter, den dein Backend lesen kann.
Braucht er die Google Cloud CLI?
Ja. Die CLI muss installiert und angemeldet sein, und für den Validator wird Python 3.10 oder neuer benötigt.
Details
Originalbeschreibung des Autors
Secures and rate limits backend services behind Google Cloud API Gateway across OpenAPI 2.0 and OpenAPI 3.0.x API configurations, including MCP-enabled gateways. Use when configuring API key or JWT authentication, locking down Cloud Run or Cloud Run functions backends with a gateway service account, reading authenticated claims from X-Apigateway-Api-Userinfo, setting per-project request quotas, or diagnosing HTTP 429 and HTTP 500 Service Control Quota errors. Do not use for Apigee, GKE Gateway API, Cloud Load Balancing custom domain setup, or LLM model routing.
repo: google/skills
Beliebtheit
- GitHub-Sterne
- 22k
- Platz im Ranking
- #10213
- Lizenz
- Apache-2.0
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
finding-google-skills
22kHilft deinem Agenten, die richtigen Google-Anleitungen für eine Einrichtungsaufgabe zu finden, etwa für Hosting, Datenbanken, Speicher, Anmeldung oder das Bereitstellen von KI-Modellen.
gcloud
22kHilft deinem Agenten, gcloud-Befehle für Google Cloud zu schreiben und zu prüfen, und schlägt die genaue Syntax nach, bevor etwas ausgeführt wird, damit keine Flags geraten werden.
google-cloud-recipe-auth
22kFührt deinen Agenten durch Identität und Zugriff in Google Cloud, einschließlich Anmeldung von Personen und Diensten und der Berechtigungen, die sie erhalten.
google-cloud-recipe-onboarding
22kFührt einen neuen Entwickler durch die ersten Schritte in Google Cloud, darunter Projektauswahl, Verknüpfung der Abrechnung und die Bereitstellung einer ersten Ressource.
Ähnliche Skills
reverse-engineer-anything
422kHilft deinem Agenten, fertige Apps und Pakete zu untersuchen, um Funktionen zu erklären, Versionen zu vergleichen oder einen Nachbau zu leiten, mit dem REA-Tool.
1password
394kHilft deinem Agenten, die 1Password-Kommandozeile einzurichten, sich anzumelden und Geheimnisse zu lesen oder einzufügen, ohne deren Werte im Chat auszugeben.
healthcheck
394kHilft deinem Agenten, den Computer oder Server, auf dem OpenClaw läuft, auf Sicherheitsrisiken wie SSH, Firewall, Updates und Backups zu prüfen und sichere Korrekturen vorzuschlagen.