The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Give the browser a real page after sign-in
shukieshah90f82ba240ba
diff --git a/cli/beacon/internal/account/login.go b/cli/beacon/internal/account/login.goindex 366cee97..f9edb106 100644--- a/cli/beacon/internal/account/login.go+++ b/cli/beacon/internal/account/login.go@@ -155,7 +155,7 @@ func Login(ctx context.Context, opts LoginOptions) (*Session, error) {if err != nil {return nil, err}- callback.SetSuccessPage("Beacon: signed in", "You are signed in to Beacon. You can close this tab and return to the terminal.")+ callback.SetSuccessPage("Signed in to Beacon", "Return to your terminal to finish setting up this machine.")defer callback.Shutdown()callback.Start()diff --git a/cli/beacon/internal/auth/auth_test.go b/cli/beacon/internal/auth/auth_test.goindex 35a0f5b6..48f9f17c 100644--- a/cli/beacon/internal/auth/auth_test.go+++ b/cli/beacon/internal/auth/auth_test.go@@ -55,7 +55,7 @@ func TestCallbackServerRunsExchangeOnceForAValidRedirect(t *testing.T) {}body, _ := io.ReadAll(resp.Body)resp.Body.Close()- if !strings.Contains(string(body), "Authentication Failed") {+ if !strings.Contains(string(body), "Sign-in failed") {t.Fatalf("expected failure page for %q, got %s", q, body)}}@@ -212,3 +212,41 @@ func TestResolveDashboardURL(t *testing.T) {t.Fatalf("flag should win over env, got %q", got)}}++// The page a browser lands on is the only Beacon surface some users see before the+// dashboard, so it carries real styling. It does not send them anywhere: the+// terminal is still mid-flow when this renders, and the command prints the+// dashboard links itself once setup finishes.+func TestSuccessPageIsStyledAndPointsAtTheTerminal(t *testing.T) {+ cs, err := NewCallbackServer("state-1", "verifier-1", func(context.Context, string, string, string) error { return nil }, time.Second)+ if err != nil {+ t.Fatal(err)+ }+ cs.SetSuccessPage("Signed in to Beacon", "Return to your terminal to finish setting up this machine.")+ cs.Start()+ defer cs.Shutdown()++ resp, err := http.Get(fmt.Sprintf("http://127.0.0.1:%d/callback?state=state-1&exchange_code=code-1", cs.Port()))+ if err != nil {+ t.Fatal(err)+ }+ body, _ := io.ReadAll(resp.Body)+ resp.Body.Close()+ page := string(body)++ for _, want := range []string{"Signed in to Beacon", "Return to your terminal", "<style>", "B E A C O N"} {+ if !strings.Contains(page, want) {+ t.Fatalf("success page missing %q:\n%s", want, page)+ }+ }+ // No redirect: the browser stays put so the terminal keeps the user's attention.+ for _, unwanted := range []string{"http-equiv=\"refresh\"", "dashboard", "<script"} {+ if strings.Contains(page, unwanted) {+ t.Fatalf("success page should not contain %q:\n%s", unwanted, page)+ }+ }+ // Nothing is fetched: this is served from loopback with no network guarantee.+ if strings.Contains(page, "<link") || strings.Contains(page, `src="http`) {+ t.Fatalf("the page must not fetch anything:\n%s", page)+ }+}diff --git a/cli/beacon/internal/auth/server.go b/cli/beacon/internal/auth/server.goindex 6b267c71..55548758 100644--- a/cli/beacon/internal/auth/server.go+++ b/cli/beacon/internal/auth/server.go@@ -6,12 +6,16 @@ import ("html""net""net/http"+ "strings""sync""time")const (- callbackReadTimeout = 10 * time.Second+ callbackReadTimeout = 10 * time.Second+ // defaultRedirectAfter is long enough to read two short lines and still short+ // enough that nobody waits on it.+ defaultRedirectAfter = 6 * time.SeconddefaultExchangeTimeout = 30 * time.SecondcallbackWriteTimeoutSlack = 5 * time.Second)@@ -66,7 +70,7 @@ func NewCallbackServer(expectedState, codeVerifier string, exchange ExchangeFuncstate: expectedState,codeVerifier: codeVerifier,exchange: exchange,- successTitle: "Beacon Authentication Complete",+ successTitle: "Signed in to Beacon",successBody: "You can close this window and return to the terminal.",}mux := http.NewServeMux()@@ -191,23 +195,84 @@ func (cs *CallbackServer) sendResponse(w http.ResponseWriter, success bool, errow.Header().Set("Content-Type", "text/html; charset=utf-8")w.Header().Set("Cache-Control", "no-store")if success {- _, _ = fmt.Fprintf(w, `<!DOCTYPE html>-<html>-<head><title>%s</title></head>-<body>- <h1>%s</h1>- <p>%s</p>-</body>-</html>`, html.EscapeString(cs.successTitle), html.EscapeString(cs.successTitle), html.EscapeString(cs.successBody))+ _, _ = fmt.Fprint(w, cs.successHTML())return}- _, _ = fmt.Fprintf(w, `<!DOCTYPE html>-<html>-<head><title>Beacon Authentication Failed</title></head>+ _, _ = fmt.Fprint(w, renderCallbackPage(callbackPage{+ Title: "Beacon: sign-in failed",+ Heading: "Sign-in failed",+ Lead: errorMsg,+ Note: "Return to your terminal and run the command again.",+ Failed: true,+ }))+}++func (cs *CallbackServer) successHTML() string {+ return renderCallbackPage(callbackPage{+ Title: cs.successTitle,+ Heading: cs.successTitle,+ Lead: cs.successBody,+ Note: "You can close this tab.",+ })+}++type callbackPage struct {+ Title string+ Heading string+ Lead string+ Note string+ Failed bool+}++// renderCallbackPage draws the one page a browser ever sees from the CLI.+//+// Everything is inline. This is served from a loopback port with no network+// guarantee behind it, so a stylesheet or font fetched from anywhere else would be+// the one thing on screen that could fail.+func renderCallbackPage(p callbackPage) string {+ accent := "#7c5cff"+ if p.Failed {+ accent = "#e5484d"+ }+ var footer strings.Builder+ if p.Note != "" {+ fmt.Fprintf(&footer, `<p class="note">%s</p>`, html.EscapeString(p.Note))+ }+ return fmt.Sprintf(`<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <title>%s</title>+ <style>+ :root { color-scheme: light dark; }+ * { box-sizing: border-box; }+ body {+ margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;+ padding: 24px; background: #0b0b0f; color: #e8e8ed;+ font: 15px/1.6 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;+ }+ .card { width: 100%%; max-width: 420px; text-align: center; }+ .mark { font-size: 11px; letter-spacing: .38em; color: %s; font-weight: 700; margin-bottom: 28px; }+ h1 { font-size: 22px; line-height: 1.3; margin: 0 0 12px; font-weight: 600; }+ .lead { margin: 0; color: #a8a8b3; }+ .note { margin: 28px 0 0; font-size: 13px; color: #74747f; }+ a { color: %s; }+ @media (prefers-color-scheme: light) {+ body { background: #fbfbfd; color: #16161a; }+ .lead { color: #5b5b66; }+ .note { color: #8a8a94; }+ }+ </style>+</head><body>- <h1>Authentication Failed</h1>- <p>%s</p>- <p>Please return to the terminal and run the command again.</p>+ <main class="card">+ <div class="mark">B E A C O N</div>+ <h1>%s</h1>+ <p class="lead">%s</p>+ %s+ </main></body>-</html>`, html.EscapeString(errorMsg))+</html>`, html.EscapeString(p.Title), accent, accent,+ html.EscapeString(p.Heading), html.EscapeString(p.Lead), footer.String())}diff --git a/cli/beacon/internal/endpoint/asymptote/enroll.go b/cli/beacon/internal/endpoint/asymptote/enroll.goindex f7f568d3..3fbc326c 100644--- a/cli/beacon/internal/endpoint/asymptote/enroll.go+++ b/cli/beacon/internal/endpoint/asymptote/enroll.go@@ -130,7 +130,7 @@ func Enroll(ctx context.Context, opts EnrollOptions) (*EnrollResult, error) {if err != nil {return nil, err}- server.SetSuccessPage("Beacon: device connected", "This machine is now forwarding to Asymptote. You can close this tab and return to the terminal.")+ server.SetSuccessPage("This device is connected", "Return to your terminal. This machine now forwards new events to Beacon.")defer func() { _ = server.Shutdown() }()server.Start()diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 2c80ff8a..42ff72f5 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -13,6 +13,12 @@ Stay up to date with the latest changes to the Agent Beacon CLI.### Unreleased+- **The browser page after sign-in is a real page** · Signing in used to land on+ unstyled markup with a bare heading. It now carries Beacon's mark and styling, and+ says the one thing that matters at that moment: return to your terminal, which is+ still waiting on you. Device approval gets the same page. Everything is inline,+ since the page is served from a loopback port with no network guarantee behind it.+- **Sign-in no longer tears down the setup screen** · The wizard used to quit tosign you in, print to plain output, block for up to five minutes, then start asecond wizard that wiped what it had just printed. Sign-in now runs inside the