feat: 新增xq0031_xq0032 ERP报表导出插件,完成功能与基建更新
1. 新增xq0031_xq0032插件:包含前后端源码、打包脚本、配置文件与插件元数据 2. 新增内网文件服务器组件:exe、启停脚本、打包脚本与配置 3. 新增敏感凭证RSA加密下发能力与存储结构 4. 新增大文件源管理表与相关API 5. 优化登录流程与会话管理,新增Chrome自动化安装工具链 6. 清理废弃插件与示例代码 7. 更新版本号至1.1.3,完善安装包与.gitignore配置
This commit is contained in:
@@ -13,7 +13,10 @@ import json
|
||||
import secrets
|
||||
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import padding
|
||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
|
||||
from controlplane.core import config
|
||||
|
||||
@@ -86,4 +89,22 @@ def _verify_blob(blob: str, pub: Ed25519PublicKey) -> dict:
|
||||
if len(sig) != 64:
|
||||
raise ValueError("bad signature len")
|
||||
pub.verify(sig, canon)
|
||||
return json.loads(canon)
|
||||
return json.loads(canon)
|
||||
|
||||
|
||||
# ==================== 执行机敏感凭证下发:RSA 加密 ====================
|
||||
def rsa_encrypt(pubkey_pem: str | bytes, plaintext: str) -> str:
|
||||
"""用执行机上报的 RSA 公钥加密敏感明文,返回 base64 密文串。
|
||||
|
||||
凭证值均为短串(口令/密钥),OAEP+SHA256 上限 ~190B(RSA-2048),已足够。
|
||||
供中心机下发 `/api/admin/creds` 时对每个敏感值加密使用。
|
||||
"""
|
||||
pem = pubkey_pem.encode() if isinstance(pubkey_pem, str) else pubkey_pem
|
||||
pub = serialization.load_pem_public_key(pem)
|
||||
if not isinstance(pub, rsa.RSAPublicKey):
|
||||
raise ValueError("pubkey 必须是 RSA 公钥")
|
||||
ct = pub.encrypt(
|
||||
plaintext.encode("utf-8"),
|
||||
padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA256()),
|
||||
algorithm=hashes.SHA256(), label=None))
|
||||
return base64.b64encode(ct).decode()
|
||||
Reference in New Issue
Block a user