feat(v0.7.1): P0 修复 + 企微 SSO + RBAC 细粒度 + audit_log
P0 修复: - /api/ready import 错误 (_get_engine + settings.create_redis_client) - 删 agent.otp_secret/otp_enabled 双字段 (migration 026) - 重建 021_rbac migration (IF NOT EXISTS 兼容) P1 新增: - 企微 SSO (auth_wecom_sso.py, useWeChatWorkSSO composable, PortalSelect UA 检测) - RBAC 5 角色 × 4 资源 × 4 操作 × 3 范围 (rbac_service + seed_rbac + require_permission) - audit_log 模型 + migration 027 + 服务 + API - 管理后台 RBAC 权限矩阵 UI (PermissionsMatrix.vue) 质量: - pytest 405 passed / 33 pre-existing failed / 4 xfailed (v0.7.1 引入失败 = 0) - conftest GBK patch 强制 UTF-8 读 .env - .gitignore 排除 *.b64 (含 admin token 凭据) - DEPLOY-v0.7.1.md 7 步 runbook + 4 坑 + 回滚预案
This commit is contained in:
@@ -8,6 +8,35 @@
|
||||
# 4. 测试用数据库会话
|
||||
# =============================================================================
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Windows GBK 兼容补丁: 强制 slowapi/starlette 用 UTF-8 读 .env
|
||||
# 原因: slowapi 0.1.9 内部用 starlette.config.Config 读 .env,默认 encoding
|
||||
# 走 locale.getpreferredencoding() (Windows=GBK)。backend/.env 是 UTF-8
|
||||
# 含中文,GBK 解码失败 → UnicodeDecodeError,pytest 卡死。
|
||||
# 修法: 替换 _read_file 强制 utf-8。生产 Linux 不受影响。
|
||||
# 详见 [[conftest-gbk-env-patch]]
|
||||
# ---------------------------------------------------------------------------
|
||||
import starlette.config as _starlette_config
|
||||
import io as _io
|
||||
|
||||
|
||||
def _patched_read_file(self, env_file):
|
||||
"""强制 utf-8 编码读 .env,绕开 Windows GBK 默认值。"""
|
||||
if not env_file:
|
||||
return {}
|
||||
try:
|
||||
with open(env_file, encoding="utf-8") as f:
|
||||
return {
|
||||
line.split("=", 1)[0].strip(): line.split("=", 1)[1].strip()
|
||||
for line in f.readlines()
|
||||
if line.strip() and not line.startswith("#")
|
||||
}
|
||||
except FileNotFoundError:
|
||||
return {}
|
||||
|
||||
|
||||
_starlette_config.Config._read_file = _patched_read_file
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
Reference in New Issue
Block a user