From 1b65f66b7bb68b298d8f9671152934a3eb394da0 Mon Sep 17 00:00:00 2001 From: Chae-JS Date: Wed, 3 Jun 2026 23:25:27 +0900 Subject: [PATCH] fix(ssh-gateway): print plain auth prompt --- cmd/ssh-gateway/auth.go | 17 +++-------------- cmd/ssh-gateway/auth_test.go | 17 ++++++----------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/cmd/ssh-gateway/auth.go b/cmd/ssh-gateway/auth.go index 54a14f8..e3d4a91 100644 --- a/cmd/ssh-gateway/auth.go +++ b/cmd/ssh-gateway/auth.go @@ -1,7 +1,6 @@ package main import ( - "encoding/base64" "errors" "fmt" "time" @@ -50,22 +49,12 @@ func kbdInteractiveAuthenticator(cfg *Config, store *sessionStore) func(ssh.Conn func formatAuthPrompt(authURLBase, nonce, code string, timeout time.Duration) string { authURL := fmt.Sprintf("%s/ssh-auth?s=%s", authURLBase, nonce) return fmt.Sprintf( - "%sRCP SSH browser authentication required.\r\n\r\n"+ + "RCP SSH browser authentication required.\r\n\r\n"+ "1. Open this URL in your browser:\r\n %s\r\n\r\n"+ - "2. Enter this 6-digit code on the auth page:\r\n%s\r\n\r\n"+ - "If your terminal supports clipboard integration, the code was copied automatically.\r\n"+ + "2. Enter this 6-digit code on the auth page: %s\r\n\r\n"+ "Waiting for browser authentication. Timeout: %s\r\n", - terminalClipboardCopy(code), - terminalHyperlink(authURL, authURL), + authURL, code, timeout, ) } - -func terminalHyperlink(url, label string) string { - return fmt.Sprintf("\x1b]8;;%s\a%s\x1b]8;;\a", url, label) -} - -func terminalClipboardCopy(text string) string { - return fmt.Sprintf("\x1b]52;c;%s\a", base64.StdEncoding.EncodeToString([]byte(text))) -} diff --git a/cmd/ssh-gateway/auth_test.go b/cmd/ssh-gateway/auth_test.go index 0a05d96..760a70d 100644 --- a/cmd/ssh-gateway/auth_test.go +++ b/cmd/ssh-gateway/auth_test.go @@ -1,7 +1,6 @@ package main import ( - "encoding/base64" "strings" "testing" "time" @@ -14,8 +13,7 @@ func TestFormatAuthPromptShowsBrowserAuthSteps(t *testing.T) { "RCP SSH browser authentication required.", "1. Open this URL in your browser:", "https://khu-return.com/ssh-auth?s=nonce-1", - "2. Enter this 6-digit code on the auth page:", - "\r\n363161\r\n", + "2. Enter this 6-digit code on the auth page: 363161", "Waiting for browser authentication. Timeout: 5m0s", } for _, s := range want { @@ -25,16 +23,13 @@ func TestFormatAuthPromptShowsBrowserAuthSteps(t *testing.T) { } } -func TestFormatAuthPromptAddsTerminalConveniences(t *testing.T) { +func TestFormatAuthPromptDoesNotEmitTerminalEscapeSequences(t *testing.T) { prompt := formatAuthPrompt("https://khu-return.com", "nonce-1", "363161", 5*time.Minute) - url := "https://khu-return.com/ssh-auth?s=nonce-1" - if !strings.Contains(prompt, "\x1b]8;;"+url+"\a"+url+"\x1b]8;;\a") { - t.Fatalf("prompt should include OSC 8 hyperlink for URL:\n%q", prompt) + if strings.Contains(prompt, "\x1b") { + t.Fatalf("prompt should not include ESC bytes:\n%q", prompt) } - - encodedCode := base64.StdEncoding.EncodeToString([]byte("363161")) - if !strings.Contains(prompt, "\x1b]52;c;"+encodedCode+"\a") { - t.Fatalf("prompt should include OSC 52 clipboard copy for code:\n%q", prompt) + if strings.Contains(prompt, "\a") { + t.Fatalf("prompt should not include BEL bytes:\n%q", prompt) } }