From 2a0ac9d1962850edc58ba5ccd4ca7f18e50a2361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Thu, 10 Apr 2025 11:23:16 +0800 Subject: [PATCH] fix(webconsole): require rdp input password (#22397) --- pkg/webconsole/service/handlers.go | 2 +- pkg/webconsole/session/remote_console_rdp.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/webconsole/service/handlers.go b/pkg/webconsole/service/handlers.go index d9d6e0474d..0a97cfa784 100644 --- a/pkg/webconsole/service/handlers.go +++ b/pkg/webconsole/service/handlers.go @@ -335,7 +335,7 @@ func handleServerRemoteRDPConsole(ctx context.Context, w http.ResponseWriter, r httperrors.GeneralServerError(ctx, w, err) return } - handleDataSession(ctx, info, w, "rdp", url.Values{"password": {info.GetPassword()}}, true) + handleDataSession(ctx, info, w, "rdp", url.Values{"password": {info.GetPassword()}}, false) } func responsePublicCloudConsole(ctx context.Context, info *session.RemoteConsoleInfo, w http.ResponseWriter) { diff --git a/pkg/webconsole/session/remote_console_rdp.go b/pkg/webconsole/session/remote_console_rdp.go index b7e6b29b45..d832641cae 100644 --- a/pkg/webconsole/session/remote_console_rdp.go +++ b/pkg/webconsole/session/remote_console_rdp.go @@ -69,9 +69,6 @@ func NewRemoteRDPConsoleInfoByCloud(ctx context.Context, s *mcclient.ClientSessi if err != nil { return nil, err } - if !ret.Contains("username") || !ret.Contains("password") { - return nil, httperrors.NewMissingParameterError("username") - } info.Password, _ = ret.GetString("password") info.Username, _ = ret.GetString("username") } @@ -99,6 +96,9 @@ func (info *RemoteRDPConsoleInfo) Scan(byte, func(string)) { } func (info *RemoteRDPConsoleInfo) IsNeedLogin() (bool, error) { + if len(info.Username) == 0 || len(info.Password) == 0 { + return true, nil + } return false, nil }