Skillpedia
الأمان35k · #7986

implementing-api-gateway-security-controls

ما الذي تفعله

تُنشئ هذه المهارة نقطة أمان مركزية لواجهات البرمجة (APIs) لديك. تحميها من الوصول غير المصرح به، وتحد من عدد مرات استدعائها، وتتحقق من أن الطلبات منسقة بشكل صحيح.

متى تستخدمها

  • ✓عندما تحتاج إلى حماية عدة واجهات برمجة بالقواعد الأمنية نفسها.
  • ✓عندما تضبط حدودًا للاستخدام لمنع الحمل الزائد.
  • ✓عندما تتحقق من أن البيانات المرسلة إلى الواجهة بالتنسيق المتوقع.

رابط المهارة

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-api-gateway-security-controls/SKILL.md

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

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

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

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

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

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

“اضبط أمان واجهة البرمجة لدي بحيث تسمح بـ100 استدعاء في الدقيقة فقط، وتحظر عناوين IP الخبيثة.”

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

كيف تعمل

تطبّق هذه المهارة قواعد الأمان مباشرة على «البوابة» (API gateway)، وهي نقطة الدخول لكل الطلبات. وهذا يضمن تطبيق الحماية قبل أن يصل الطلب إلى الخدمة الرئيسية.

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

النص الأصلي من المؤلف، مباشرة من GitHub.

Implementing API Gateway Security Controls

When to Use

  • Deploying a centralized authentication and authorization layer for microservice APIs
  • Implementing rate limiting, throttling, and quota management across all API endpoints
  • Configuring request/response validation against OpenAPI specifications at the gateway level
  • Setting up TLS termination, mutual TLS, and certificate management for API traffic
  • Integrating WAF rules with the API gateway to block injection, XSS, and known attack patterns

Do not use as the sole security layer. API gateways provide defense in depth but backend services must also validate authorization and input.

Prerequisites

  • API gateway platform selected and deployed (Kong, AWS API Gateway, Azure APIM, or Apigee)
  • OpenAPI/Swagger specifications for all backend APIs
  • TLS certificates for the gateway domain
  • Identity provider (IdP) configured for OAuth2/OIDC (Okta, Auth0, Azure AD)
  • Monitoring and logging infrastructure (CloudWatch, Datadog, ELK)
  • Backend service endpoints registered and reachable from the gateway

Workflow

Step 1: Kong Gateway Security Configuration

# kong.yml - Declarative Kong configuration with security plugins
_format_version: "3.0"

services:
  - name: user-service
    url: http://user-service:8080
    routes:
      - name: user-api
        paths:
          - /api/v1/users
        methods:
          - GET
          - POST
          - PUT
          - PATCH
          - DELETE
        strip_path: false

plugins:
  # 1. Authentication: JWT validation
  - name: jwt
    config:
      uri_param_names:
        - jwt
      header_names:
        - Authorization
      claims_to_verify:
        - exp
      maximum_expiration: 3600  # Max 1 hour token TTL

  # 2. Rate Limiting
  - name: rate-limiting
    config:
      minute: 60
      hour: 1000
      policy: redis
      redis_host: redis
      redis_port: 6379
      fault_tolerant: true
      hide_client_headers: false
      limit_by: credential  # Per-user, not per-IP

  # 3. Request Size Limiting
  - name: request-size-limiting
    config:
      allowed_payload_size: 1  # 1 MB max
      size_unit: megabytes

  # 4. IP Restriction (admin endpoints)
  - name: ip-restriction
    service: admin-service
    config:
      allow:
        - 10.0.0.0/8
        - 172.16.0.0/12

  # 5. Bot Detection
  - name: bot-detection
    config:
      deny:
        - "sqlmap"
        - "nikto"
        - "nmap"
        - "masscan"

  # 6. CORS Configuration
  - name: cors
    config:
      origins:
        - "https://app.example.com"
      methods:
        - GET
        - POST
        - PUT
        - PATCH
        - DELETE
      headers:
        - Authorization
        - Content-Type
      credentials: true
      max_age: 3600

  # 7. Response Transformer - Remove sensitive headers
  - name: response-transformer
    config:
      remove:
        headers:
          - X-Powered-By
          - Server
      add:
        headers:
          - "X-Content-Type-Options: nosniff"
          - "X-Frame-Options: DENY"
          - "Strict-Transport-Security: max-age=31536000; includeSubDomains"
          - "Content-Security-Policy: default-src 'none'"

Step 2: AWS API Gateway Security Configuration

import boto3
import json

apigw = boto3.client('apigatewayv2')

# Create API with mutual TLS
api_response = apigw.create_api(
    Name='secure-api',
    ProtocolType='HTTP',
    DisableExecuteApiEndpoint=True,  # Force custom domain
)
api_id = api_response['ApiId']

# Configure authorizer (JWT with Cognito)
authorizer = apigw.create_authorizer(
    ApiId=api_id,
    AuthorizerType='JWT',
    IdentitySource='$request.header.Authorization',
    Name='cognito-jwt-authorizer',
    JwtConfiguration={
        'Audience': ['your-app-client-id'],
        'Issuer': 'https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxx'
    }
)

# Create route with authorizer
apigw.create_route(
    ApiId=api_id,
    RouteKey='GET /api/v1/users',
    AuthorizerId=authorizer['AuthorizerId'],
    AuthorizationType='JWT',
)

# Configure throttling
apigw.create_stage(
    ApiId=api_id,
    StageName='prod',
    DefaultRouteSettings={
        'ThrottlingBurstLimit': 100,
        'ThrottlingRateLimit': 50.0,  # 50 requests per second
    },
    AccessLogSettings={
        'DestinationArn': 'arn:aws:logs:us-east-1:123456789:log-group:api-access-logs',
        'Format': json.dumps({
            'requestId': '$context.requestId',

…
الأسئلة الشائعة

ما هي بوابة واجهة البرمجة (API Gateway)؟

هي تشبه البواب لواجهات البرمجة لديك. تستقبل كل الطلبات، وتتحقق من صحتها، وتحوّلها إلى الخدمة المناسبة، مع تطبيق قواعد الأمان في الطريق.

ما هو rate limiting؟

هو حد لعدد مرات وصول المستخدم أو عنوان IP إلى واجهة البرمجة خلال إطار زمني معين، لمنع إساءة الاستخدام أو الحمل الزائد.

هل يمكنني استخدامها كطبقة الأمان الوحيدة؟

لا. البوابة طبقة دفاع مهمة، لكن الخدمات الخلفية تحتاج أيضًا إلى فحوص أمان خاصة بها.

التفاصيل

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

Configures API gateways such as Kong, AWS API Gateway, Azure APIM, or Apigee as a centralized security enforcement point, covering authentication enforcement, rate limiting and throttling, request validation, IP allowlisting, TLS termination, and threat protection. Use when securing API traffic at the gateway layer, setting up gateway-level authentication and quota management, or centralizing API

repo: mukul975/Anthropic-Cybersecurity-Skills

الشعبية

نجوم GitHub
35k
الترتيب
#7986
الترخيص
Apache-2.0
آخر تحديث
31‏/8‏/2026

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

0

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

التعليقات

  • …

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

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