← ClaudeAtlas

implementing-api-gateway-security-controlslisted

在API网关层实施安全控制,包括认证强制执行、速率限制、请求验证、IP白名单、TLS终止和威胁防护。 配置API网关(Kong、AWS API Gateway、Azure APIM、Apigee)作为集中式安全执行点, 在流量到达后端服务前对所有API流量进行验证、节流和监控。
killvxk/cybersecurity-skills-zh · ★ 15 · API & Backend · score 81
Install: claude install-skill killvxk/cybersecurity-skills-zh
# 实施API网关安全控制 ## 适用场景 - 为微服务API部署集中式认证和授权层 - 对所有API端点实施速率限制、节流和配额管理 - 在网关级别根据OpenAPI规范配置请求/响应验证 - 为API流量设置TLS终止、双向TLS和证书管理 - 将WAF规则与API网关集成,阻断注入、XSS和已知攻击模式 **不适用**作为唯一安全层。API网关提供纵深防御,但后端服务也必须验证授权和输入。 ## 前置条件 - 已选择并部署API网关平台(Kong、AWS API Gateway、Azure APIM或Apigee) - 所有后端API的OpenAPI/Swagger规范 - 网关域名的TLS证书 - 已为OAuth2/OIDC配置身份提供商(IdP)(Okta、Auth0、Azure AD) - 监控和日志基础设施(CloudWatch、Datadog、ELK) - 后端服务端点已注册并可从网关访问 ## 工作流程 ### 步骤1:Kong网关安全配置 ```yaml # kong.yml - 带安全插件的声明式Kong配置 _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. 认证:JWT验证 - name: jwt config: uri_param_names: - jwt header_names: - Authorization claims_to_verify: - exp maximum_expiration: 3600 # 令牌最大有效期1小时 # 2. 速率限制 - 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 # 按用户而非按IP # 3. 请求大小限制 - name: request-size-limiting config: allowed_payload_size: 1 # 最大1MB size_unit: megabytes # 4. IP限制(管理端点) - name: ip-restriction service: admin-service config: allow: - 10.0.0.0/8 - 172.16