feat: 新增设备登录开关配置,优化 CI Go 模块缓存机制,并添加解密中间件调试日志。
Build docker and publish / prepare (20.15.1) (push) Successful in 10s
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.admin image_name:ppanel-admin name:admin]) (push) Successful in 1m16s
Build docker and publish / deploy (push) Has been cancelled
Build docker and publish / notify (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.rpc-core image_name:ppanel-rpc-core name:rpc-core]) (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.scheduler image_name:ppanel-scheduler name:scheduler]) (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.node image_name:ppanel-node name:node]) (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.queue image_name:ppanel-queue name:queue]) (push) Has been cancelled
Build docker and publish / build (map[dockerfile:deploy/Dockerfile.api image_name:ppanel-api name:api]) (push) Has been cancelled

This commit is contained in:
2026-03-01 20:21:02 -08:00
parent d3da56891b
commit b8dab70de5
7 changed files with 171 additions and 10 deletions
+3
View File
@@ -49,6 +49,9 @@ Security:
Enable: true
SecuritySecret: "uB4G,XxL2{7b"
Device:
Enable: true
Asynq:
Addr: 127.0.0.1:6379
+3
View File
@@ -23,4 +23,7 @@ type Config struct {
Enable bool
SecuritySecret string
}
Device struct {
Enable bool
}
}
@@ -34,6 +34,11 @@ func NewDeviceLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Devic
}
func (l *DeviceLoginLogic) DeviceLogin(req *types.DeviceLoginReq) (resp *types.LoginResp, err error) {
// todo: 新建设备登录是否禁用逻辑
if !l.svcCtx.Config.Device.Enable {
return nil, xerr.NewErrCode(xerr.DeviceLoginDisabled)
}
// 1. 调用 Core RPC 设备登录
rpcResp, err := l.svcCtx.CoreRpc.DeviceLogin(l.ctx, &core.DeviceLoginReq{
Identifier: req.Identifier,
@@ -8,6 +8,7 @@ import (
"io"
"net"
"net/http"
"net/url"
"strings"
"github.com/zero-ppanel/zero-ppanel/apps/api/internal/config"
@@ -26,6 +27,8 @@ func NewDecryptMiddleware(c config.Config) *DecryptMiddleware {
func (m *DecryptMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fmt.Printf("[DEBUG] DecryptMiddleware entered, Security.Enable=%v, Login-Type=%q\n",
m.conf.Security.Enable, r.Header.Get("Login-Type"))
if !m.conf.Security.Enable {
next(w, r)
return
@@ -86,7 +89,12 @@ func (m *DecryptMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
httpx.Error(w, xerr.NewErrCode(xerr.DecryptFailed))
return
}
fmt.Printf("[DEBUG] decrypted body: %s\n", string(plain))
r.Body = io.NopCloser(bytes.NewBuffer(plain))
// 防止 httpx.Parse 内部的 r.ParseForm() 消费已替换的 body
// ParseForm 首行检查 r.PostForm == nil,置空后它不会再读 body。
r.PostForm = url.Values{}
r.ContentLength = int64(len(plain))
}
next(rw, r)