mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
申请ACME证书时可以指定平台用户
This commit is contained in:
@@ -18,31 +18,6 @@ func (this *CreateAction) Init() {
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunGet(params struct{}) {
|
||||
// 获取所有可用的用户
|
||||
usersResp, err := this.RPC().ACMEUserRPC().FindAllACMEUsers(this.AdminContext(), &pb.FindAllACMEUsersRequest{
|
||||
AdminId: this.AdminId(),
|
||||
UserId: 0,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
userMaps := []maps.Map{}
|
||||
for _, user := range usersResp.AcmeUsers {
|
||||
description := user.Description
|
||||
if len(description) > 0 {
|
||||
description = "(" + description + ")"
|
||||
}
|
||||
|
||||
userMaps = append(userMaps, maps.Map{
|
||||
"id": user.Id,
|
||||
"description": description,
|
||||
"email": user.Email,
|
||||
"providerCode": user.AcmeProviderCode,
|
||||
})
|
||||
}
|
||||
this.Data["users"] = userMaps
|
||||
|
||||
// 证书服务商
|
||||
providersResp, err := this.RPC().ACMEProviderRPC().FindAllACMEProviders(this.AdminContext(), &pb.FindAllACMEProvidersRequest{})
|
||||
if err != nil {
|
||||
@@ -81,14 +56,15 @@ func (this *CreateAction) RunGet(params struct{}) {
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunPost(params struct {
|
||||
TaskId int64
|
||||
AuthType string
|
||||
AcmeUserId int64
|
||||
DnsProviderId int64
|
||||
DnsDomain string
|
||||
Domains []string
|
||||
AutoRenew bool
|
||||
AuthURL string
|
||||
PlatformUserId int64
|
||||
TaskId int64
|
||||
AuthType string
|
||||
AcmeUserId int64
|
||||
DnsProviderId int64
|
||||
DnsDomain string
|
||||
Domains []string
|
||||
AutoRenew bool
|
||||
AuthURL string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
@@ -117,7 +93,7 @@ func (this *CreateAction) RunPost(params struct {
|
||||
if len(params.Domains) == 0 {
|
||||
this.Fail("请输入证书域名列表")
|
||||
}
|
||||
realDomains := []string{}
|
||||
var realDomains = []string{}
|
||||
for _, domain := range params.Domains {
|
||||
domain = strings.ToLower(domain)
|
||||
if params.AuthType == "dns" { // DNS认证
|
||||
@@ -134,6 +110,7 @@ func (this *CreateAction) RunPost(params struct {
|
||||
|
||||
if params.TaskId == 0 {
|
||||
createResp, err := this.RPC().ACMETaskRPC().CreateACMETask(this.AdminContext(), &pb.CreateACMETaskRequest{
|
||||
UserId: params.PlatformUserId,
|
||||
AuthType: params.AuthType,
|
||||
AcmeUserId: params.AcmeUserId,
|
||||
DnsProviderId: params.DnsProviderId,
|
||||
|
||||
@@ -12,6 +12,8 @@ type RunAction struct {
|
||||
func (this *RunAction) RunPost(params struct {
|
||||
TaskId int64
|
||||
}) {
|
||||
defer this.CreateLogInfo("执行ACME任务 %d", params.TaskId)
|
||||
|
||||
runResp, err := this.RPC().ACMETaskRPC().RunACMETask(this.AdminContext(), &pb.RunACMETaskRequest{AcmeTaskId: params.TaskId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package acme
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UserOptionsAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UserOptionsAction) RunPost(params struct {
|
||||
PlatformUserId int64
|
||||
}) {
|
||||
// 获取所有可用的用户
|
||||
usersResp, err := this.RPC().ACMEUserRPC().FindAllACMEUsers(this.AdminContext(), &pb.FindAllACMEUsersRequest{
|
||||
AdminId: 0,
|
||||
UserId: params.PlatformUserId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var userMaps = []maps.Map{}
|
||||
for _, user := range usersResp.AcmeUsers {
|
||||
description := user.Description
|
||||
if len(description) > 0 {
|
||||
description = "(" + description + ")"
|
||||
}
|
||||
|
||||
userMaps = append(userMaps, maps.Map{
|
||||
"id": user.Id,
|
||||
"description": description,
|
||||
"email": user.Email,
|
||||
"providerCode": user.AcmeProviderCode,
|
||||
})
|
||||
}
|
||||
this.Data["users"] = userMaps
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -16,10 +16,30 @@ func (this *CreatePopupAction) Init() {
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunGet(params struct {
|
||||
ProviderCode string
|
||||
PlatformUserId int64
|
||||
ProviderCode string
|
||||
}) {
|
||||
this.Data["platformUserId"] = params.PlatformUserId
|
||||
this.Data["providerCode"] = params.ProviderCode
|
||||
|
||||
// 平台用户信息
|
||||
this.Data["platformUser"] = nil
|
||||
if params.PlatformUserId > 0 {
|
||||
platformUserResp, err := this.RPC().UserRPC().FindEnabledUser(this.AdminContext(), &pb.FindEnabledUserRequest{UserId: params.PlatformUserId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var platformUser = platformUserResp.User
|
||||
if platformUser != nil {
|
||||
this.Data["platformUser"] = maps.Map{
|
||||
"id": platformUser.Id,
|
||||
"username": platformUser.Username,
|
||||
"fullname": platformUser.Fullname,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 服务商
|
||||
providersResp, err := this.RPC().ACMEProviderRPC().FindAllACMEProviders(this.AdminContext(), &pb.FindAllACMEProvidersRequest{})
|
||||
if err != nil {
|
||||
@@ -40,10 +60,11 @@ func (this *CreatePopupAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunPost(params struct {
|
||||
Email string
|
||||
ProviderCode string
|
||||
AccountId int64
|
||||
Description string
|
||||
PlatformUserId int64
|
||||
Email string
|
||||
ProviderCode string
|
||||
AccountId int64
|
||||
Description string
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
@@ -85,6 +106,7 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
createResp, err := this.RPC().ACMEUserRPC().CreateACMEUser(this.AdminContext(), &pb.CreateACMEUserRequest{
|
||||
UserId: params.PlatformUserId,
|
||||
Email: params.Email,
|
||||
Description: params.Description,
|
||||
AcmeProviderCode: params.ProviderCode,
|
||||
|
||||
@@ -41,6 +41,7 @@ func init() {
|
||||
Post("/run", new(acme.RunAction)).
|
||||
GetPost("/updateTaskPopup", new(acme.UpdateTaskPopupAction)).
|
||||
Post("/deleteTask", new(acme.DeleteTaskAction)).
|
||||
Post("/userOptions", new(acme.UserOptionsAction)).
|
||||
|
||||
// ACME用户
|
||||
Prefix("/servers/certs/acme/users").
|
||||
|
||||
Reference in New Issue
Block a user