BitzOrcas 通过 ASP.NET Core 标准中间件管道配置 CORS 和安全头。
CORS 策略
// 在 ApiPipelineRegistration 中配置// 开发环境:宽松以支持本地开发// 生产环境:限制为已知来源配置
{ "Cors": { "AllowedOrigins": ["https://app.example.com", "https://admin.example.com"], "AllowedMethods": ["GET", "POST", "PUT", "PATCH", "DELETE"], "AllowedHeaders": ["Content-Type", "Authorization", "X-Idempotency-Key", "X-Correlation-Id", "X-Signature", "X-API-Key"], "AllowCredentials": true, "MaxAgeSeconds": 3600 }}安全头
生产推荐安全头:
X-Content-Type-Options: nosniffX-Frame-Options: DENYX-XSS-Protection: 0 (已弃用,优先使用 CSP)Referrer-Policy: strict-origin-when-cross-originContent-Security-Policy: default-src 'none'; frame-ancestors 'none'Permissions-Policy: camera=(), microphone=(), geolocation=()Nonce 存储
BitzOrcas 注册 nonce 存储用于 HMAC 防重放:
services.AddSingleton<INonceStore, MemoryNonceStore>();自定义头
| 头 | 方向 | 用途 |
|---|---|---|
X-Correlation-Id | 响应 | 请求关联标识符 |
X-Tenant-Id | 响应(调试) | 解析的租户标识符 |
Retry-After | 响应(429) | 允许重试前的秒数 |
另见
- 生产检查清单 — 部署安全设置