refactor: jdmc license

This commit is contained in:
Bai
2026-03-13 17:22:55 +08:00
parent 447225aa12
commit ce2d0ff3b3
5 changed files with 25 additions and 3 deletions

View File

@@ -10,6 +10,15 @@ from rest_framework.views import APIView
from common.signals import webhook_signal
# 记录所有支持的 webhook 事件,供文档和测试使用
WEBHOOK_OPTIONS_RECORD = [
{
'sender': 'jdmc',
'event': 'license_updated',
}
]
class WebhookApi(APIView):
"""
data:

View File

@@ -781,6 +781,8 @@
"LevelApproval": "Level approval",
"License": "License",
"LicenseExpired": "The license has expired",
"LicenseMaintenanceExpired": "The license maintenance period has expired",
"LicenseWillExpire": "The license will expire soon",
"LicenseFile": "License file",
"LicenseForTest": "Test purpose license, this license is only for testing (poc) and demonstration",
"LicenseReachedAssetAmountLimit": "The assets has exceeded the license limit",

View File

@@ -782,6 +782,8 @@
"LevelApproval": "级审批",
"License": "许可证",
"LicenseExpired": "许可证已经过期",
"LicenseMaintenanceExpired": "许可证维保时间已过期",
"LicenseWillExpire": "许可证即将过期",
"LicenseFile": "许可证文件",
"LicenseForTest": "测试用途许可证, 本许可证仅用于 测试PoC和演示",
"LicenseReachedAssetAmountLimit": "资产数量已经超过许可证数量限制",

View File

@@ -754,7 +754,7 @@ class Config(dict):
# JDMC
'JDMC_ENABLED': False,
'JDMC_SOCK_PATH': '',
'JDMC_LICENSE_PUBLIC_KEY_PATH': '',
'JDMC_PUBLIC_KEY_PATH': '',
# WEBHOOK
'WEBHOOK_ENABLED': False,

View File

@@ -2,7 +2,7 @@
#
from pathlib import Path
from urllib.parse import quote
from cryptography.hazmat.primitives import serialization
from .base import TEMPLATES, STATIC_DIR
from ..const import CONFIG
@@ -281,7 +281,16 @@ if Path(VENDOR_TEMPLATES_DIR).is_dir():
JDMC_ENABLED = CONFIG.JDMC_ENABLED
JDMC_SOCK_PATH = CONFIG.JDMC_SOCK_PATH
JDMC_BASE_URL = f"http+unix://{quote(JDMC_SOCK_PATH, safe='')}"
JDMC_LICENSE_PUBLIC_KEY_PATH = CONFIG.JDMC_LICENSE_PUBLIC_KEY_PATH
JDMC_PUBLIC_KEY_PATH = CONFIG.JDMC_PUBLIC_KEY_PATH
JDMC_PUBLIC_KEY = None
if JDMC_PUBLIC_KEY_PATH:
try:
with open(JDMC_PUBLIC_KEY_PATH, 'rb') as f:
jdmc_public_key = f.read()
JDMC_PUBLIC_KEY = serialization.load_pem_public_key(jdmc_public_key)
except Exception as exc:
print(f'Failed to load JDMC public key: {exc}')
# WebHook
WEBHOOK_ENABLED = CONFIG.WEBHOOK_ENABLED