pipeline-llm/scripts/load_path.py

50 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""pipeline_llm module RBAC permission registration.
Run from app root: py3/bin/python pkgs/pipeline-llm/scripts/load_path.py
Requires app-root wrapper set_role_perm.py.
v1 推理端点(/pipeline-llm/api/v1/*)授权给 any运行环境/外部客户端用短期
Bearer token 鉴权,没有登录会话。端点文件内含 verify_llm_tokensecurity_check
AUTH_PATTERNS 认可)。其余管理页/CRUD 全部 logined。
"""
import subprocess
MOD = "pipeline-llm"
PATHS_ANY = [
# 推理 APIBearer 短期 token 鉴权,无登录会话
f"/{MOD}/api/v1/chat/completions",
f"/{MOD}/api/v1/models",
# API 文档端点:公开文档(照 sage /bricks/docs any 先例),外部开发者调 API 前可查;
# index.ui 按 _lang 分发四语言 mdmd 由 ApiDoc 组件拉取——都需匿名可读
f"/{MOD}/api/v1/docs",
f"/{MOD}/api/v1/docs/",
f"/{MOD}/api/v1/docs/**",
]
PATHS_LOGINED = [
f"/{MOD}/",
f"/{MOD}/index.ui",
]
# api/(管理)与生成的 CRUD 目录用通配符一次覆盖
PATHS_WILDCARD_LOGINED = [
f"/{MOD}/**",
]
def register_paths():
for path in PATHS_ANY:
subprocess.run(["py3/bin/python", "set_role_perm.py", "any", path])
print(f" any: {path}")
for path in PATHS_LOGINED + PATHS_WILDCARD_LOGINED:
subprocess.run(["py3/bin/python", "set_role_perm.py", "logined", path])
print(f" logined: {path}")
if __name__ == "__main__":
print(f"=== {MOD} (pipeline_llm) RBAC registration ===")
register_paths()
print("Done.")