api-gateway-backend-security-and-rate-limiting
Secures and rate limits backend services behind Google Cloud API Gateway across OpenAPI 2.0 and OpenAPI 3.x API configurations, including MCP-enabled…
от google★ 25 380 звёзд на GitHub
Установить api-gateway-backend-security-and-rate-limiting в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
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.x (3.0.x and 3.1.x, such as openapi: 3.0.4), including gateways with Model Context Protocol (MCP) enabled (Public Preview).
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read and follow the instructions in
Usage Attribution.
Prerequisites
- Install the Google Cloud CLI and Python 3.10+ YAML parser:
- If
gcloudis not installed, give the user the Google Cloud CLI install guide. Do not install it yourself. Until it is installed, give the user the commands to run, and continue from the output that they paste. - If the gcloud CLI is old, ask the user before you run
gcloud components update. An old gcloud CLI can fail when it uploads an OpenAPI 3.x spec. - Install
PyYAMLfor the quota metric validation script. Ask the user before you install it:pip install "PyYAML>=6.0,<7.0"
- If
- 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:
- Ask the user which project to use, and use that ID as
{project_id}. Pass--project={project_id}on every command. Do not rungcloud config set project, because it changes the default project for all other work of the user. If no project exists, create one withgcloud 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.
- Ask the user which project to use, and use that ID as
- 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 - To change the IAM policy of the Cloud Run backend (grant the invoker role, remove
allUsers, and turn on the invoker IAM check):roles/run.admin, or another role withrun.services.get,run.services.getIamPolicy,run.services.setIamPolicy, andrun.services.update. For a 1st gen function backend:roles/cloudfunctions.admin - 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 in the x-api-key header (use the key or api_key query parameter only as an 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. API Gateway ignores an API key scheme with any other name or location, with no error, and the operation then accepts calls with no key. | 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 + |
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/attribution.md
- references/backend-security.md
- references/client-authentication.md
- references/mcp-traffic-security.md
- references/quotas-and-rate-limiting.md
- scripts/check_quota_metrics.py
FAQ
Что делает скилл api-gateway-backend-security-and-rate-limiting?
Secures and rate limits backend services behind Google Cloud API Gateway across OpenAPI 2.0 and OpenAPI 3.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 changing quota metrics without the HTTP 500 "Failed to call Service Control Quota" error on older gateways. Do not use for finding the cause of failing requests from gateway logs, such as an unexplained HTTP 429 or 5xx (use api-gateway-troubleshooting), writing or migrating a whole spec (use api-gateway-openapi-spec-authoring), MCP tool setup (use api-gateway-mcp-server), Apigee, GKE Gateway API, Cloud Load Balancing custom domain setup, or LLM model routing.
Как установить скилл api-gateway-backend-security-and-rate-limiting?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-gateway-backend-security-and-rate-limiting запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…