78f60c6857
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 坑 + 回滚预案
57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
"""v4 - 最干净的版本,无中文 docstring,纯 ASCII,堡垒机粘贴不会破坏。
|
|
"""
|
|
import asyncio
|
|
import os
|
|
import sys
|
|
import traceback
|
|
|
|
os.chdir("/app")
|
|
sys.path.insert(0, "/app")
|
|
|
|
import redis.asyncio as aioredis
|
|
|
|
print("[DEBUG] REDIS_URL env =", repr(os.environ.get("REDIS_URL")))
|
|
|
|
try:
|
|
from app.config import settings
|
|
print("[DEBUG] settings.redis_url =", repr(settings.redis_url))
|
|
except Exception as e:
|
|
print("[ERROR] import settings:", e)
|
|
traceback.print_exc()
|
|
sys.exit(1)
|
|
|
|
REDIS_URL = os.environ.get("REDIS_URL") or settings.redis_url
|
|
print("[DEBUG] using REDIS_URL =", repr(REDIS_URL))
|
|
|
|
|
|
async def main():
|
|
redis = aioredis.from_url(REDIS_URL, protocol=2, decode_responses=True)
|
|
try:
|
|
await redis.ping()
|
|
print("[DEBUG] redis ping OK")
|
|
except Exception as e:
|
|
print("[ERROR] redis ping failed:", e)
|
|
traceback.print_exc()
|
|
await redis.close()
|
|
sys.exit(2)
|
|
|
|
from app.services.token_service import TokenService
|
|
svc = TokenService(redis)
|
|
token = await svc.create_token(
|
|
employee_id="dev-admin-001",
|
|
name="admin",
|
|
roles=["admin"],
|
|
department="IT",
|
|
login_source="prod-cli",
|
|
)
|
|
print("ADMIN_TOKEN=" + token)
|
|
await redis.close()
|
|
|
|
|
|
try:
|
|
asyncio.run(main())
|
|
except Exception as e:
|
|
print("[FATAL]", e)
|
|
traceback.print_exc()
|
|
sys.exit(99)
|