- user_scopes 由"假开关"做成生效:粒度到项目级(组织隔离 ∧ 项目∈范围,取交集);未配置=不限制(逐字向后兼容);
总管理员豁免;脏数据保守忽略不锁死;配置期校验存在性+归属;逐接口叠加(列表/详情/写操作/Excel 导出落 scope_project_ids);
前端新增"数据范围"弹窗入口。顺带修 GET /api/charge-orders 此前完全没有组织隔离(跨租户泄露)、
GET /api/projects/{id}/cabinets 的 500
- 数据库列类型系统性对齐:扫描并修复 pms_dev 32 项 / pms 18 项漂移(时间列统一 DATETIME,sqlx NaiveDateTime 只兼容 DATETIME);
DECIMAL→BIGINT 与列注释口径拉平;修复生产 GET /api/charge-orders、GET /api/device-logs 必然 500 的根因;
恢复 7 张表丢失的 updated_at ON UPDATE(行为变化,已记入 AGENTS.md);修正 SCHEMA_SQL 前向引用(空库建表必崩);
新增 tools/db_schema_diff.py(漂移检查,退出码可接部署前置)与 test/schema_alignment_e2e.py
- 安全加固四项:上传去 .svg + 魔数嗅探(堵存储型 XSS);登录失败锁定(5次/15分)+challenge 限流+并发闸门+验证码容差收紧;
服务降权 root→pms;nginx 安全头 + limit_req + CORS 白名单收敛
- TCP 连接登录门控(上行+下行同一规则):login 前只放行 auth_str/login(PRE_LOGIN_ALLOWED_ACTS)
- 状态位按归属层级展示:柜级 status1/status2 显示在柜子(含柜门 + 开门按钮,独立动作不联动业务)、
仓体级 batt_status/pow_status 显示在仓体;两端解析函数同源同名
- 能耗报表改实时聚合 charge_records(原 energy_stats 全表只读不写导致报表恒 0)+ 补复合索引
- 组织可见性:新增 GET /api/my-organizations(工厂全量、客户仅本组织)
- 仓体 status 仅表占用,充满/故障由 Redis 通道状态派生
- 订单/占用/队列运维缺口:h5 建单漏单、214 仓体自愈、device:reports 上限、死信 TTL、LimitNOFILE、
每日 mysqldump + 回滚点保留 5 次
- 文档:AGENTS.md 补层级可见性/数据范围/状态位约定/数据库工具/行为变化;docs/API.md 删除废弃 TCP 章节、接口总表对齐 mod.rs
90 lines
3.5 KiB
Plaintext
90 lines
3.5 KiB
Plaintext
server {
|
||
listen 80;
|
||
server_name app.anzhizhichong.com;
|
||
return 301 https://$server_name$request_uri;
|
||
}
|
||
|
||
server {
|
||
listen 443 ssl http2;
|
||
server_name app.anzhizhichong.com;
|
||
|
||
ssl_certificate /etc/nginx/ssl/app.anzhizhichong.com.pem;
|
||
ssl_certificate_key /etc/nginx/ssl/app.anzhizhichong.com.key;
|
||
ssl_protocols TLSv1.2 TLSv1.3;
|
||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||
|
||
# ===== 安全响应头(2026-09 安全加固)=====
|
||
# HSTS:本域强制 HTTPS(暂不加 includeSubDomains,避免影响未知子域)
|
||
add_header Strict-Transport-Security "max-age=31536000" always;
|
||
# 禁止 MIME 嗅探:/uploads 免认证同源直出,防上传内容被当 HTML/JS 执行
|
||
add_header X-Content-Type-Options "nosniff" always;
|
||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||
# CSP 先 Report-Only 观察(只上报不拦截),确认 SPA 无违规后再考虑收紧为强制
|
||
add_header Content-Security-Policy-Report-Only "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'self'" always;
|
||
|
||
# 产品介绍页
|
||
root /data/landing;
|
||
index index.html;
|
||
|
||
location /doc/ {
|
||
proxy_pass http://127.0.0.1:3080/;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
client_max_body_size 500m;
|
||
}
|
||
|
||
# 登录接口限流(防暴力破解第二道;第一道在 api-server 内按手机号+IP 计数锁定)
|
||
location = /api/pms/auth/login {
|
||
limit_req zone=auth_login_zone burst=10 nodelay;
|
||
proxy_pass http://127.0.0.1:9000/api/auth/login;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
}
|
||
|
||
# 验证码接口限流(免认证且逐像素渲染,是 CPU 放大攻击面)
|
||
location = /api/pms/auth/challenge {
|
||
limit_req zone=auth_challenge_zone burst=10 nodelay;
|
||
proxy_pass http://127.0.0.1:9000/api/auth/challenge;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
}
|
||
|
||
location /api/pms/ {
|
||
proxy_pass http://127.0.0.1:9000/api/;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
client_max_body_size 10m;
|
||
}
|
||
|
||
# 头像上传文件(免认证同源直出)——限流;nosniff 由 server 级继承
|
||
location /uploads/ {
|
||
limit_req zone=uploads_zone burst=60 nodelay;
|
||
proxy_pass http://127.0.0.1:9000/uploads/;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
expires 30d;
|
||
}
|
||
|
||
# PMS管理前端 - 不带斜杠时重定向
|
||
location = /pms {
|
||
return 301 /pms/;
|
||
}
|
||
|
||
# PMS管理前端
|
||
location /pms/ {
|
||
alias /data/pms/web/;
|
||
try_files $uri $uri/ /pms/index.html;
|
||
}
|
||
}
|