Skip to content

Commit 6a2d3f9

Browse files
committed
修改工作流主方法,修改证书申请
1 parent eb61724 commit 6a2d3f9

File tree

6 files changed

+56
-3
lines changed

6 files changed

+56
-3
lines changed

backend/app/api/acme_account.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,13 @@ func GetAccountList(c *gin.Context) {
125125
}
126126
public.SuccessData(c, accounts, total)
127127
}
128+
129+
func GetCaList(c *gin.Context) {
130+
cas, total, err := apply.GetCaList()
131+
if err != nil {
132+
public.FailMsg(c, err.Error())
133+
return
134+
}
135+
public.SuccessData(c, cas, total)
136+
137+
}

backend/internal/cert/apply/account.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,34 @@ func GetAccountList(search, ca string, p, limit int64) ([]map[string]interface{}
228228

229229
return data, int(count), nil
230230
}
231+
232+
func GetCaList() ([]string, int, error) {
233+
db, err := GetSqlite()
234+
if err != nil {
235+
return nil, 0, fmt.Errorf("failed to get sqlite: %w", err)
236+
}
237+
data, err := db.Field([]string{"type"}).GroupBy("type").Select()
238+
if err != nil {
239+
return nil, 0, fmt.Errorf("failed to get CA list: %w", err)
240+
}
241+
caList := []string{"letsencrypt", "buypass", "zerossl"}
242+
for i := range data {
243+
if data[i]["type"] == "Let's Encrypt" {
244+
data[i]["type"] = "letsencrypt"
245+
}
246+
if !containsString(caList, data[i]["type"].(string)) {
247+
caList = append(caList, data[i]["type"].(string))
248+
}
249+
}
250+
count := len(caList)
251+
return caList, count, nil
252+
}
253+
254+
func containsString(slice []string, target string) bool {
255+
for _, v := range slice {
256+
if v == target {
257+
return true
258+
}
259+
}
260+
return false
261+
}

backend/internal/cert/apply/apply.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,15 @@ func GetAcmeClient(email, algorithm, eabId, ca string, httpClient *http.Client,
343343
}
344344
}
345345
}
346-
var reg *registration.Resource
346+
var (
347+
reg *registration.Resource
348+
Kid, HmacEncoded string
349+
)
347350
if eabData != nil {
351+
Kid = eabData["Kid"].(string)
352+
HmacEncoded = eabData["HmacEncoded"].(string)
353+
}
354+
if Kid != "" && HmacEncoded != "" {
348355
Kid := eabData["Kid"].(string)
349356
HmacEncoded := eabData["HmacEncoded"].(string)
350357
reg, err = client.Registration.RegisterWithExternalAccountBinding(registration.RegisterEABOptions{

backend/internal/cert/deploy/plugin/deploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ func Deploy(cfg map[string]any, logger *public.Logger) error {
8383
// 调用插件
8484
logger.Debug(fmt.Sprintf("调用插件%s:%s", pluginName, action))
8585

86-
rep, err := CallPlugin(pluginName, action, pluginConfig, logger)
86+
_, err = CallPlugin(pluginName, action, pluginConfig, logger)
8787
if err != nil {
8888
return fmt.Errorf("调用插件失败:%v", err)
8989
}
90-
fmt.Println(rep)
90+
//fmt.Println(rep)
9191
return err
9292
}

backend/internal/workflow/workflow.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ func RunNode(node *WorkflowNode, ctx *ExecutionContext) error {
286286
}
287287

288288
if node.ChildNode != nil {
289+
fromNodeData, ok := ctx.GetOutput(node.Id)
290+
if ok && fromNodeData != nil && node.ChildNode.Config["fromNodeData"] == nil {
291+
node.ChildNode.Config["fromNodeData"] = fromNodeData
292+
}
289293
return RunNode(node.ChildNode, ctx)
290294
}
291295
return nil

backend/route/route.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func Register(r *gin.Engine) {
6060
acmeAccount := v1.Group("/acme_account")
6161
{
6262
acmeAccount.POST("/get_list", api.GetAccountList)
63+
acmeAccount.POST("/get_ca_list", api.GetCaList)
6364
acmeAccount.POST("/add_account", api.AddAccount)
6465
acmeAccount.POST("/del_account", api.DelAccount)
6566
acmeAccount.POST("/upd_account", api.UpdateAccount)

0 commit comments

Comments
 (0)