diff --git a/apps/common/api/webhook.py b/apps/common/api/webhook.py index 14efb20a9..a61f9dd2e 100644 --- a/apps/common/api/webhook.py +++ b/apps/common/api/webhook.py @@ -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: diff --git a/apps/i18n/lina/en.json b/apps/i18n/lina/en.json index 158b7c824..b6620a9f3 100644 --- a/apps/i18n/lina/en.json +++ b/apps/i18n/lina/en.json @@ -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", diff --git a/apps/i18n/lina/zh.json b/apps/i18n/lina/zh.json index fd786f577..1feae9b8b 100644 --- a/apps/i18n/lina/zh.json +++ b/apps/i18n/lina/zh.json @@ -782,6 +782,8 @@ "LevelApproval": "级审批", "License": "许可证", "LicenseExpired": "许可证已经过期", + "LicenseMaintenanceExpired": "许可证维保时间已过期", + "LicenseWillExpire": "许可证即将过期", "LicenseFile": "许可证文件", "LicenseForTest": "测试用途许可证, 本许可证仅用于 测试(PoC)和演示", "LicenseReachedAssetAmountLimit": "资产数量已经超过许可证数量限制", diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index 5d2cf11ea..dd7296705 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -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, diff --git a/apps/jumpserver/settings/custom.py b/apps/jumpserver/settings/custom.py index 9f970c1b6..4b1639f15 100644 --- a/apps/jumpserver/settings/custom.py +++ b/apps/jumpserver/settings/custom.py @@ -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