mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-04-10 20:53:16 +08:00
Merge pull request #485 from LystranG/feat-safaline-portal
feat: 雷池waf认证中心证书上传功能
This commit is contained in:
@@ -77,6 +77,9 @@ func Deploy(cfg map[string]any, logger *public.Logger) error {
|
||||
case "safeline-panel":
|
||||
logger.Debug("部署雷池WAF面板...")
|
||||
return DeploySafeLineWaf(cfg)
|
||||
case "safeline-portal":
|
||||
logger.Debug("部署雷池WAF认证中心...")
|
||||
return DeploySafeLineWafPortal(cfg, logger)
|
||||
case "localhost":
|
||||
logger.Debug("部署到本地...")
|
||||
return DeployLocalhost(cfg)
|
||||
|
||||
@@ -79,8 +79,11 @@ func GetSafeLineWafSiteList(page int, pageSize int, siteName string, providerId
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := response["data"].(map[string]any)
|
||||
return res["data"].([]any), nil
|
||||
data, ok := response["data"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("雷池WAF站点列表响应格式错误")
|
||||
}
|
||||
return data["data"].([]any), nil
|
||||
}
|
||||
|
||||
func matchSafeLineSiteByColumn(siteList []any, column string, keyword string) (siteInfo map[string]any) {
|
||||
@@ -93,6 +96,18 @@ func matchSafeLineSiteByColumn(siteList []any, column string, keyword string) (s
|
||||
return siteInfo
|
||||
}
|
||||
|
||||
func GetSafeLineWafPortalConfig(providerID string) (map[string]any, error) {
|
||||
response, err := RequestSafeLineWaf(&map[string]any{}, "GET", providerID, "api/open/portal")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data, ok := response["data"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("雷池WAF门户配置响应格式错误: data 字段不是对象")
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// 上传证书 certId="" 新上传证书 否则覆盖证书
|
||||
func uploadSafeLineCert(certId float64, key, cert, providerId string) (id float64, err error) {
|
||||
data := map[string]any{
|
||||
@@ -206,6 +221,59 @@ func DeploySafeLineWafSite(cfg map[string]any, logger *public.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeploySafeLineWafPortal 部署证书到雷池WAF认证中心
|
||||
func DeploySafeLineWafPortal(cfg map[string]any, logger *public.Logger) error {
|
||||
cert, ok := cfg["certificate"].(map[string]any)
|
||||
if !ok {
|
||||
return fmt.Errorf("证书不存在")
|
||||
}
|
||||
keyPem, ok := cert["key"].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("证书错误:key")
|
||||
}
|
||||
certPem, ok := cert["cert"].(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("证书错误:cert")
|
||||
}
|
||||
var providerID string
|
||||
switch v := cfg["provider_id"].(type) {
|
||||
case float64:
|
||||
providerID = strconv.Itoa(int(v))
|
||||
case string:
|
||||
providerID = v
|
||||
default:
|
||||
return fmt.Errorf("参数错误:provider_id")
|
||||
}
|
||||
|
||||
portalCfg, err := GetSafeLineWafPortalConfig(providerID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("获取认证中心配置失败: %s", err.Error())
|
||||
}
|
||||
|
||||
var portalCertId float64
|
||||
if v, ok := portalCfg["cert_id"].(float64); ok {
|
||||
portalCertId = v
|
||||
}
|
||||
|
||||
// 上传/更新证书
|
||||
if portalCertId == 0 {
|
||||
logger.Debug("认证中心未启用证书,上传证书中...")
|
||||
certId, err := uploadSafeLineCert(0, keyPem, certPem, providerID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("认证中心上传证书失败: %s", err.Error())
|
||||
}
|
||||
logger.Debug(fmt.Sprintf("认证中心上传证书成功 证书ID:%d 请手动添加至认证中心", int(certId)))
|
||||
} else {
|
||||
logger.Debug(fmt.Sprintf("认证中心已启用证书ID:%d,更新证书中...", int(portalCertId)))
|
||||
_, err = uploadSafeLineCert(portalCertId, keyPem, certPem, providerID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("认证中心更新证书失败: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func SafeLineAPITest(providerID string) error {
|
||||
_, err := RequestSafeLineWaf(&map[string]any{}, "GET", providerID, "api/open/site/group")
|
||||
if err != nil {
|
||||
|
||||
@@ -46,6 +46,15 @@ func TestGetSafeLineWAFSiteList(t *testing.T) {
|
||||
fmt.Println(siteId)
|
||||
}
|
||||
|
||||
func TestSafeLineWAFPortalGet(t *testing.T) {
|
||||
res, err := GetSafeLineWafPortalConfig("1")
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
return
|
||||
}
|
||||
fmt.Println(res)
|
||||
}
|
||||
|
||||
func TestSafeLineAPITest(t *testing.T) {
|
||||
result := SafeLineAPITest("5")
|
||||
if result != nil {
|
||||
@@ -53,4 +62,4 @@ func TestSafeLineAPITest(t *testing.T) {
|
||||
} else {
|
||||
t.Log("SafeLineAPITest success")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11744,5 +11744,22 @@
|
||||
"arDZ": "الرجاء إدخال اسم الشهادة للبحث"
|
||||
},
|
||||
"timestamp": "2025-11-19T09:00:47.861Z"
|
||||
},
|
||||
"雷池WAF-认证中心": {
|
||||
"text": "雷池WAF-认证中心",
|
||||
"key": "t_0_1770278647457",
|
||||
"translations": {
|
||||
"zhCN": "雷池WAF-认证中心",
|
||||
"zhTW": "雷池WAF-認證中心",
|
||||
"enUS": "LeiChi WAF - Authentication Center",
|
||||
"jaJP": "雷池WAF-認証センター",
|
||||
"koKR": "뢰지WAF-인증센터",
|
||||
"ruRU": "LeiChi WAF - Центр аутентификации",
|
||||
"ptBR": "LeiChi WAF - Centro de Autenticação",
|
||||
"frFR": "LeiChi WAF - Centre d'authentification",
|
||||
"esAR": "LeiChi WAF - Centro de Autenticación",
|
||||
"arDZ": "واقي LeiChi WAF - مركز المصادقة"
|
||||
},
|
||||
"timestamp": "2026-02-05T08:04:07.457Z"
|
||||
}
|
||||
}
|
||||
@@ -270,6 +270,7 @@ export interface DeployConfig<
|
||||
| "qiniu-oss"
|
||||
| "safeline-site"
|
||||
| "safeline-panel"
|
||||
| "safeline-portal"
|
||||
| "btpanel-dockersite"
|
||||
| "lecdn" // LeCDN 部署类型
|
||||
| "plugin" // 新增插件类型
|
||||
|
||||
@@ -143,6 +143,7 @@ export const ApiProjectConfig: Record<string, ApiProjectType> = {
|
||||
hostRelated: {
|
||||
panel: { name: $t("t_1_1747298114192") },
|
||||
site: { name: $t("t_12_1747886302725") },
|
||||
portal: { name: $t("t_0_1770278647457") },
|
||||
},
|
||||
sort: 8,
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "واقي LeiChi WAF - مركز المصادقة",
|
||||
"t_0_1744098811152": "تحذير: لقد دخلتم منطقة غير معروفة، الصفحة التي تحاول زيارتها غير موجودة، يرجى الضغط على الزر للعودة إلى الصفحة الرئيسية.",
|
||||
"t_1_1744098801860": "رجوع إلى الصفحة الرئيسية",
|
||||
"t_2_1744098804908": "نصيحة أمنية: إذا كنت تعتقد أن هذا خطأ، يرجى الاتصال بالمدير على الفور",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "LeiChi WAF - Authentication Center",
|
||||
"t_0_1744098811152": "Warning: You have entered an unknown area, the page you are visiting does not exist, please click the button to return to the homepage.",
|
||||
"t_1_1744098801860": "Return Home",
|
||||
"t_2_1744098804908": "Safety Tip: If you think this is an error, please contact the administrator immediately",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "LeiChi WAF - Centro de Autenticación",
|
||||
"t_0_1744098811152": "Advertencia: Ha ingresado a una zona desconocida, la página que intenta visitar no existe, por favor, haga clic en el botón para regresar a la página de inicio.",
|
||||
"t_1_1744098801860": "Volver al inicio",
|
||||
"t_2_1744098804908": "Consejo de seguridad: Si piensa que es un error, póngase en contacto con el administrador inmediatamente",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "LeiChi WAF - Centre d'authentification",
|
||||
"t_0_1744098811152": "Avertissement : Vous avez entré dans une zone inconnue, la page que vous visitez n'existe pas, veuillez cliquer sur le bouton pour revenir à la page d'accueil.",
|
||||
"t_1_1744098801860": "Retour à l'accueil",
|
||||
"t_2_1744098804908": "Avis de sécurité : Si vous pensez que c'est une erreur, veuillez contacter l'administrateur immédiatement",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "雷池WAF-認証センター",
|
||||
"t_0_1744098811152": "警告:未知のエリアに進入しました。アクセスしようとしたページは存在しません。ボタンをクリックしてホームページに戻ってください。",
|
||||
"t_1_1744098801860": "ホームに戻る",
|
||||
"t_2_1744098804908": "安全注意:これが誤りだと思われる場合は、すぐに管理者に連絡してください",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "뢰지WAF-인증센터",
|
||||
"t_0_1744098811152": "경고: 알 수 없는 영역에 진입했습니다. 방문하려는 페이지가 존재하지 않습니다. 버튼을 클릭하여 홈페이지로 돌아가세요。",
|
||||
"t_1_1744098801860": "홈으로 돌아가기",
|
||||
"t_2_1744098804908": "안전 유의사항: 이가 오류라면 즉시 관리자에게 연락하십시오",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "LeiChi WAF - Centro de Autenticação",
|
||||
"t_0_1744098811152": "Aviso: Você entrou em uma área desconhecida, a página que você está visitando não existe, por favor, clique no botão para voltar para a página inicial.",
|
||||
"t_1_1744098801860": "Voltar para a homepage",
|
||||
"t_2_1744098804908": "Dica de Segurança: Se você acha que isso é um erro, entre em contato com o administrador imediatamente",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "LeiChi WAF - Центр аутентификации",
|
||||
"t_0_1744098811152": "Предупреждение: Вы вошли в неизвестную зону, посещаемая страница не существует, пожалуйста, нажмите кнопку, чтобы вернуться на главную страницу.",
|
||||
"t_1_1744098801860": "Вернуться на главную",
|
||||
"t_2_1744098804908": "Совет по безопасности: Если вы считаете, что это ошибка, немедленно свяжитесь с администратором",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "雷池WAF-认证中心",
|
||||
"t_0_1744098811152": "警告:您已进入未知区域,所访问的页面不存在,请点击按钮返回首页。",
|
||||
"t_1_1744098801860": "返回首页",
|
||||
"t_2_1744098804908": "安全提示:如果您认为这是个错误,请立即联系管理员",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"t_0_1770278647457": "雷池WAF-認證中心",
|
||||
"t_0_1744098811152": "警告:您已進入未知區域,所訪問的頁面不存在,請點擊按鈕返回首頁。",
|
||||
"t_1_1744098801860": "返回首頁",
|
||||
"t_2_1744098804908": "安全提示:如果您認為這是個錯誤,請立即聯繫管理員",
|
||||
|
||||
Reference in New Issue
Block a user