mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-10 20:40:56 +08:00
[SSL证书]免费证书申请增加HTTP认证方式
This commit is contained in:
33
internal/rpc/services/service_acme_authentication.go
Normal file
33
internal/rpc/services/service_acme_authentication.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
// ACME认证相关
|
||||
type ACMEAuthenticationService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
// 获取Key
|
||||
func (this *ACMEAuthenticationService) FindACMEAuthenticationKeyWithToken(ctx context.Context, req *pb.FindACMEAuthenticationKeyWithTokenRequest) (*pb.FindACMEAuthenticationKeyWithTokenResponse, error) {
|
||||
_, err := this.ValidateNode(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(req.Token) == 0 {
|
||||
return nil, errors.New("'token' should not be empty")
|
||||
}
|
||||
|
||||
auth, err := models.SharedACMEAuthenticationDAO.FindAuthWithToken(req.Token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if auth == nil {
|
||||
return &pb.FindACMEAuthenticationKeyWithTokenResponse{Key: ""}, nil
|
||||
}
|
||||
return &pb.FindACMEAuthenticationKeyWithTokenResponse{Key: auth.Key}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user