fix(webui): keep the dashboard token out of the startup log
DashboardURL no longer takes a token, so the startup line cannot embed ?t=<token> in the printed URL. The log now names the token file instead.
This commit is contained in:
1 parent
2b514cb526
commit
b107e4452a
2 files changed
+14
-11
No files matched your search
@@ -116,13 +116,18 @@ func Run(ctx context.Context, options Options) error {
|
||||
return fmt.Errorf("listen for ui: %w", err)
|
||||
}
|
||||
cleanups = append(cleanups, func() { _ = listener.Close() })
|
||||
log.Info(
|
||||
"archie-ui running",
|
||||
attrs := []any{
|
||||
"addr", listener.Addr().String(),
|
||||
"open", webui.DashboardURL(listener.Addr().String(), opts.Token),
|
||||
"open", webui.DashboardURL(listener.Addr().String()),
|
||||
"gateway", opts.Gateway.Target,
|
||||
"state", opts.State.Target,
|
||||
)
|
||||
}
|
||||
// Name the file holding the token, never the token itself: this line
|
||||
// reaches the journal and any log an operator pastes.
|
||||
if opts.TokenFile != "" {
|
||||
attrs = append(attrs, "token_file", opts.TokenFile)
|
||||
}
|
||||
log.Info("archie-ui running", attrs...)
|
||||
|
||||
return serve(ctx, listener, srv.Handler(), opts)
|
||||
}
|
||||
|
||||
@@ -57,8 +57,10 @@ func IsLoopback(listen string) bool {
|
||||
}
|
||||
|
||||
// DashboardURL renders a listen address as an openable URL, with localhost
|
||||
// for wildcard hosts.
|
||||
func DashboardURL(listen, token string) string {
|
||||
// for wildcard hosts. It deliberately carries no credential: a URL is safe to
|
||||
// log and paste, so the dashboard token can only be read from the file the
|
||||
// operator named, never from a printed link.
|
||||
func DashboardURL(listen string) string {
|
||||
host, port, err := net.SplitHostPort(strings.TrimSpace(listen))
|
||||
if err != nil {
|
||||
host, port = "", strings.TrimPrefix(strings.TrimSpace(listen), ":")
|
||||
@@ -67,11 +69,7 @@ func DashboardURL(listen, token string) string {
|
||||
case "", "0.0.0.0", "::", "[::]":
|
||||
host = "localhost"
|
||||
}
|
||||
url := "http://" + net.JoinHostPort(host, port) + "/"
|
||||
if token != "" {
|
||||
url += "?t=" + token
|
||||
}
|
||||
return url
|
||||
return "http://" + net.JoinHostPort(host, port) + "/"
|
||||
}
|
||||
|
||||
// LoadOrCreateToken returns the dashboard token, generating and persisting one
|
||||
|
||||
Reference in new issue
Block a user