Skillpedia
الأمان22k · #10213

api-gateway-backend-security-and-rate-limiting

ما الذي تفعله

تساعد هذه المهارة وكيل الذكاء الاصطناعي على تأمين واجهة برمجية تعمل خلف API Gateway في Google Cloud. وهي مناسبة للمطورين الذين يريدون التحكم في من يستدعي واجهتهم وكم مرة.

متى تستخدمها

  • ✓عندما تريد اشتراط مفاتيح API أو رموز دخول قبل أن يستطيع الناس استدعاء واجهتك على Google Cloud.
  • ✓عندما تحتاج إلى حماية خلفية Cloud Run بحيث لا يصل إليها إلا بوابة API.
  • ✓عندما تريد تحديد حدود طلبات لكل مشروع لخدمة API Gateway.

رابط المهارة

https://github.com/google/skills/blob/main/skills/cloud/api-gateway-backend-security-and-rate-limiting/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/google/skills/blob/main/skills/cloud/api-gateway-backend-security-and-rate-limiting/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“أمّن واجهتي على Google Cloud بحيث لا يستدعيها إلا مستخدمون مسجلو الدخول بمفتاح صالح، واحدّد عدد الطلبات التي يستطيعون إرسالها.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تحدّث المهارة ملف تعريف الواجهة لإضافة فحوص تسجيل الدخول وحساب خدمة للبوابة إلى الخلفية وحدود لكل مشروع. كما تشغّل فحوص تحقق على الإعدادات.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من 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

  1. Install the Google Cloud CLI and Python 3.10+ YAML parser:
    • Install or update the Google Cloud SDK.
    • Install PyYAML for the quota metric validation script:
      pip install "PyYAML>=6.0,<7.0"
      
  2. 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}
  3. 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-central1 as the default --location for API Gateway commands. For the other supported regions, see API Gateway deployment model.
  4. Enable required Google Cloud APIs:
    gcloud services enable \
      apigateway.googleapis.com \
      servicemanagement.googleapis.com \
      servicecontrol.googleapis.com \
      iam.googleapis.com \
      apikeys.googleapis.com \
      --project={project_id}
    
    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.
  5. Verify required IAM roles:
    • To manage API Gateway resources and enable services: roles/apigateway.admin and roles/serviceusage.serviceUsageAdmin
    • To create the gateway service account and attach it to an API config: roles/iam.serviceAccountAdmin and roles/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) or roles/cloudfunctions.invoker (1st gen functions)

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
الأسئلة الشائعة

ما صيغ ملفات الواجهات المدعومة؟

تدعم ملفات OpenAPI 2.0 وOpenAPI 3.0.x، بما فيها البوابات التي فعّلت MCP.

هل تستطيع خلفيتي أن تعرف من يستدعيها؟

نعم. تمرر البوابة بيانات المستخدم المسجل في ترويسة يستطيع الخادم الخلفي قراءتها.

هل تحتاج إلى Google Cloud CLI؟

نعم. يجب تثبيت CLI وتسجيل الدخول إليه، ويلزم Python 3.10 أو أحدث للمدقق.

التفاصيل

الوصف الأصلي من المؤلف

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

الشعبية

نجوم GitHub
22k
الترتيب
#10213
الترخيص
Apache-2.0
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة