feat: 上线前安全加固与发布工程化;appmall 由插件迁移为独立应用
安全(P0) - 发布包签名:新增 scripts/package_keygen.php、scripts/package_verify.php、 ywxapp\service\PackageVerifier;FrameworkService::apply() 解压前强制验签 (ywxapp.framework_package_verify,默认开启) - JWT 收紧:config/jwt.php 移除公开默认密钥,JwtService::assertStrongSecret() 校验非空 / 长度≥32 / 已知弱值;.env.production.example 键名由 JWT_SECRET_KEY 修正为 JWT_SECRET - /api/v1/Article:免登录白名单收窄为只读接口,写操作字段白名单 + assertOwner() 越权校验 - 开发者令牌:查找接口不再回显明文、统一失败文案 + 限流 - TemplateInstaller:文件名白名单 + realpath 归一化 + 目录内断言,修复 Zip Slip;补 use ZipArchive - 后台登录:接入验证码、失败锁定与登录限流(config/ratelimit.php) - 缓存 / Session 驱动可由 .env 覆盖(CACHE_DRIVER / SESSION_TYPE),集群部署改 redis - paycenter 支付日志开关改为 PAY_LOG,不再跟随 APP_DEBUG 工程化 / 交付 - 新增 CHANGELOG.md 与 .env.production.example;composer.lock 入库锁定依赖版本 - 插件离线安装 CLI 增加 --uid,后台上传安装透传 uid,付费插件授权校验可通过 - 授权拒绝文案区分「未携带 uid」与「未找到有效授权」,便于排障 - .gitignore 放行 .env.production.example / .env.addon.example / .gitattributes / public/.htaccess 结构 - appmall 由 addon/appmall 迁移为独立应用 app/appmall(市场 / 开发者中心 / 审核 / 分润)
This commit is contained in:
1 parent
1d49e6f5ee
commit
18101cf11a
636 files changed
+58517
-9519
No files matched your search
+57
-8
@@ -6,14 +6,63 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: ywxapp<admin@ywxapp.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 分层跨域配置。本文件被 **两套** CORS 机制读取,改动前务必读完注释:
|
||||
//
|
||||
// A. ywxapp\middleware\CrossDomain(本项目自研,真正的执行者)
|
||||
// → 读 app_cross(按应用名分层白名单)+ allowed_methods/headers/max_age/credentials
|
||||
// B. think\cors\HandleCors(topthink/think-cors,经服务发现自动挂载,见 vendor/services.php)
|
||||
// → 读 paths / allowed_origins / allowed_methods / allowed_headers / exposed_headers ...
|
||||
// 注意:它的构造函数会对 allowed_methods / allowed_headers 执行 array_map,
|
||||
// 因此这两项**必须是数组**;写成 'GET, POST' 这样的字符串会在每个请求
|
||||
// 构造函数里抛 TypeError(array_map(): Argument #2 must be of type array, string given)。
|
||||
//
|
||||
// 现状:跨域已由 CrossDomain 分层接管,think-cors 保持「空转」(paths 为空 → 不匹配任何路径)。
|
||||
// 若将来想让 think-cors 真正接管,把 paths 配上路径即可,但**必须先移除 CrossDomain**,
|
||||
// 否则两条链路会重复输出 CORS 头。
|
||||
//
|
||||
// app_cross 按应用名取规则,取值:
|
||||
// '*' 全放开(无凭证模式,公开 API 可用)
|
||||
// 'a.com,b.com' 精确白名单(支持凭证)
|
||||
// '*.example' 通配子域
|
||||
// '' 禁止跨域(默认;同源页面不受影响)
|
||||
//
|
||||
// 安全策略:backend / member / frontend 一律留空(零跨域),
|
||||
// 仅 api 对外开放;生产建议把 api 也收紧为精确白名单。
|
||||
return [
|
||||
'paths' => [],
|
||||
'allowed_origins' => ['*'],
|
||||
'app_cross' => [
|
||||
'api' => env('CORS_API_ORIGINS', '*'),
|
||||
'backend' => env('CORS_BACKEND_ORIGINS', ''),
|
||||
'member' => env('CORS_MEMBER_ORIGINS', ''),
|
||||
'frontend' => env('CORS_FRONTEND_ORIGINS', ''),
|
||||
// 未列出的应用(含 addon 应用、index 兜底)默认禁跨域
|
||||
'default' => env('CORS_ORIGINS', ''),
|
||||
],
|
||||
|
||||
// 预检/实际请求允许的方法(**数组**,think-cors 强制要求)
|
||||
'allowed_methods' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
|
||||
|
||||
// 允许的请求头(**数组**,含本框架 JWT 鉴权实际使用的 Authorization / Authorization-Refresh)
|
||||
'allowed_headers' => [
|
||||
'Content-Type',
|
||||
'Authorization',
|
||||
'Authorization-Refresh',
|
||||
'X-Requested-With',
|
||||
'X-CSRF-TOKEN',
|
||||
'token',
|
||||
'X-Token',
|
||||
],
|
||||
|
||||
// 预检结果缓存(秒)
|
||||
'max_age' => 86400,
|
||||
|
||||
// 白名单模式下允许携带 Cookie 凭证(对 '*' 无效,浏览器强制忽略)
|
||||
'supports_credentials' => true,
|
||||
|
||||
// ==================== 以下为 think-cors 专用,保持空转 ====================
|
||||
// 空数组 → HandleCors::hasMatchingPath() 恒 false → 直接放行,不再输出任何 CORS 头。
|
||||
// 不要配成 'api/*' 之类,否则与 CrossDomain 重复输出。
|
||||
'paths' => [],
|
||||
'allowed_origins' => [],
|
||||
'allowed_origins_patterns' => [],
|
||||
'allowed_methods' => ['*'],
|
||||
'allowed_headers' => ['*'],
|
||||
'exposed_headers' => [],
|
||||
'max_age' => 0,
|
||||
'supports_credentials' => false,
|
||||
'exposed_headers' => [],
|
||||
];
|
||||
Reference in new issue
Block a user