<?php

return [
    // 统一响应配置
    'response' => [
        'success_code' => 'SUCCESS',
        'default_message' => '操作成功',
        'trace_id_header' => 'X-Trace-Id',
    ],

    // 分页配置
    'default_page_size' => env('KYLIN_PAGE_SIZE', 15),
    'max_page_size' => env('KYLIN_MAX_PAGE_SIZE', 100),

    // 缓存前缀
    'cache_prefix' => env('KYLIN_CACHE_PREFIX', 'kylin'),

    /*
     * 请求频率限制配置
     */
    'rate_limit' => [
        // 全局 API 默认限流：每分钟最大请求数
        'global_max_attempts' => env('KYLIN_RATE_LIMIT_GLOBAL', 120),
        // 全局 API 限流时间窗口（分钟）
        'global_decay_minutes' => env('KYLIN_RATE_LIMIT_DECAY', 1),

        // 敏感接口（登录/注册/验证码）限流
        'auth_max_attempts' => env('KYLIN_RATE_LIMIT_AUTH', 5),
        'auth_decay_minutes' => env('KYLIN_RATE_LIMIT_AUTH_DECAY', 1),

        // 游戏接入接口限流
        'game_max_attempts' => env('KYLIN_RATE_LIMIT_GAME', 10),
        'game_decay_minutes' => env('KYLIN_RATE_LIMIT_GAME_DECAY', 1),
    ],

    /*
     * 法律合规 - 安全响应头
     *
     * 依据等保 2.0 (GB/T 22239) 8.1.4.3，通信安全需配置安全响应头。
     */
    'security_headers' => [
        'enabled' => env('KYLIN_SECURITY_HEADERS', true),

        // X-Content-Type-Options：防止 MIME 类型嗅探
        'x_content_type_options' => 'nosniff',

        // X-Frame-Options：防止点击劫持
        'x_frame_options' => 'DENY',

        // X-XSS-Protection：XSS 过滤
        'x_xss_protection' => '1; mode=block',

        // Referrer-Policy：控制 Referer 信息
        'referrer_policy' => 'strict-origin-when-cross-origin',

        // Permissions-Policy：限制浏览器功能
        'permissions_policy' => 'camera=(), microphone=(), geolocation=()',

        // Content-Security-Policy (CSP)：防御 XSS 和数据注入
        'csp' => [
            'enabled' => env('KYLIN_CSP_ENABLED', true),
            'default_src' => "'self'",
            'script_src' => "'self' 'unsafe-inline' 'unsafe-eval'",
            'style_src' => "'self' 'unsafe-inline'",
            'img_src' => "'self' data: https:",
            'font_src' => "'self'",
            'connect_src' => "'self'",
            'frame_src' => "'none'",
            'object_src' => "'none'",
        ],

        // Strict-Transport-Security (HSTS)
        'hsts' => [
            'enabled' => env('KYLIN_HSTS_ENABLED', false), // 生产环境启用
            'max_age' => 31536000,                         // 1 年
            'include_subdomains' => true,
            'preload' => false,
        ],
    ],

    // 调试配置
    'debug' => [
        'enabled' => env('KYLIN_DEBUG', false),
        'log_queries' => env('KYLIN_LOG_QUERIES', false),
    ],
];
