mirror of
https://github.com/YFGaia/dify-plus.git
synced 2026-06-04 10:14:00 +08:00
17832f2424
本次提交整合了多个功能改进和问题修复: 主要功能: - 批量工作流处理功能完善,支持 Excel 上传和进度跟踪 - 管理中心反向代理和转发配置优化 - 用户同步添加互斥锁,防止并发问题 - 计费系统和额度显示优化 - AI 绘图功能扩展 前端改进: - 文本生成应用显示修复 - 批量任务进度展示优化 - 按钮样式和 CSS 优化,禁止换行 - 多语言支持完善(新增印尼语等) - 构建镜像逻辑优化 - 批量处理进度管理器实现 后端改进: - Docker Compose 配置升级 - 队列任务和 Worker Pool 优化 - Admin API 初始化和验证逻辑改进 - 数据库迁移和初始化完善 - 静态变量处理优化 - URL 签名助手实现 - Celery 扩展优化 - 代码和导入包问题修复(idea 自动调整代码位置) 技术改进: - 兼容性修复 (flask-restx, jschardet) - 钉钉 Web API 版本更新 - 代码格式化和导入包问题修复 - 日志处理优化 - 工作流循环管理优化 Docker 相关: - Nginx 配置更新 - 容器启动脚本优化 - 镜像构建流程改进 - docker-compose.dify-plus.yaml 大幅更新 管理后台: - 工作流批量处理 API 实现 - 工作池初始化 - 批量工作流服务实现 - 转发扩展配置 - 用户服务扩展
59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
import base64
|
|
|
|
from Crypto.Cipher import Blowfish
|
|
from Crypto.Util.Padding import unpad
|
|
|
|
from configs import dify_config
|
|
|
|
from .engine import db
|
|
|
|
|
|
class SystemIntegrationClassify:
|
|
SYSTEM_INTEGRATION_DINGTALK = 1 # 钉钉
|
|
SYSTEM_INTEGRATION_WEIXIN = 2 # 微信
|
|
SYSTEM_INTEGRATION_FEI_SU = 3 # 飞书
|
|
SYSTEM_INTEGRATION_OAUTH_TWO = 4 # OAuth2
|
|
|
|
|
|
class SystemIntegrationExtend(db.Model):
|
|
__tablename__ = "system_integration_extend"
|
|
__table_args__ = (
|
|
db.PrimaryKeyConstraint("id", name="system_integration_joins_pkey"),
|
|
db.Index("system_integration_joins_classify_idx", "classify"),
|
|
)
|
|
id = db.Column(db.BigInteger, db.Sequence("system_integration_id_sequence"), primary_key=True, autoincrement=True)
|
|
classify = db.Column(db.Integer, nullable=False, server_default=db.text("1"))
|
|
status = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
|
|
corp_id = db.Column(db.String(120), nullable=True)
|
|
agent_id = db.Column(db.String(120), nullable=True)
|
|
app_id = db.Column(db.String(120), nullable=True)
|
|
app_key = db.Column(db.String(120), nullable=True)
|
|
app_secret = db.Column(db.Text, nullable=True)
|
|
config = db.Column(db.Text, nullable=True)
|
|
|
|
def decodeSecret(self):
|
|
if len(self.app_secret) == 0:
|
|
return ""
|
|
# Decode the base64 encoded text
|
|
ciphertext = base64.b64decode(self.app_secret)
|
|
|
|
# Ensure the text length is sufficient
|
|
if len(ciphertext) < Blowfish.block_size:
|
|
raise ValueError("Invalid ciphertext")
|
|
|
|
# Extract the initialization vector (IV) from the beginning of the ciphertext
|
|
iv = ciphertext[:Blowfish.block_size]
|
|
ciphertext = ciphertext[Blowfish.block_size:]
|
|
|
|
# Create the cipher object and decrypt the plaintext
|
|
cipher = Blowfish.new(dify_config.SECRET_KEY.encode('utf-8'), Blowfish.MODE_CBC, iv)
|
|
plaintext = cipher.decrypt(ciphertext)
|
|
|
|
# Unpad the plaintext using PKCS7 unpadding
|
|
try:
|
|
plaintext = unpad(plaintext, Blowfish.block_size)
|
|
except ValueError as e:
|
|
raise ValueError("Invalid padding") from e
|
|
|
|
return plaintext.decode('utf-8')
|