web

package
v0.3.0-rc.53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 54 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package web serves what people look at: the public pages at the site's root (the status pages, or a page that names the deployment), and under /console the console, Beacon's own workbench, with the pages people open from the chat (an alert's page, with its timeline and the sessions on its machines, and a session's page, with its replay). They are HTML from embedded templates on the design system @openlinkos/ui (vendored under static/ol), without a build step or a framework, served by beacon beside the API on the same port, in the configured language, readable on a phone. Every page says it runs on Beacon and links to the project (brand.go).

People sign in to the console with their Beacon account, a username and a password (console.go, accounts.go), and what the console may do is what their role allows; signing in with a pasted token is kept for one release. People manage their agents there (agentpages.go), owners manage people, and MCP clients are allowed at /oauth/authorize (oauth.go). An alert's or a session's page also opens without signing in, view-only, with a signed link (package link), which the card, the chat echoes and the API hand out, or with a bearer credential carrying the scope the matching API route needs; anything else is 404, so that a wrong or expired link reveals nothing, not even that the page exists. Text from outside Beacon reaches the pages cleaned by the bridge and is escaped by html/template on the way out; the pages carry no inline script or style, and their Content-Security-Policy allows nothing from elsewhere.

Index

Constants

View Source
const CSP = "default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self'; font-src 'self'; img-src 'self' data:; " +
	"connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'"

CSP is the pages' Content-Security-Policy: scripts, styles and fonts from Beacon itself only (the player's terminal runs as WebAssembly, hence wasm-unsafe-eval), no inline script or style, fetches and forms to Beacon only.

Variables

This section is empty.

Functions

func ReportingFrom

func ReportingFrom(m *metrics.Metrics) func() map[string]time.Time

ReportingFrom reads when each probe location or host last wrote through the gateway from the metric the gateway keeps (beacon_gateway_last_write_timestamp_seconds), for Server.Reporting.

Types

type Server

type Server struct {
	Bridge   *bridge.Bridge
	SSH      *sshgate.Gate
	Auth     *api.Auth
	Pages    *link.Pages
	Lang     i18n.Lang
	Location *time.Location
	Log      *slog.Logger
	Now      func() time.Time

	Store                 *store.Store
	Config                *configdb.Service
	Settings              *config.Manager
	Credentials           *secrets.Service
	CredentialsConfigured bool
	Hooks                 []config.Agent
	Reporting             func() map[string]time.Time
	Version               string
	DefaultWorkspace      bool

	// Status computes the public status pages (status.go); nil leaves them out.
	Status   *status.Service
	Branding config.Branding

	// OAuth is Beacon's authorization server for MCP clients (package oauth); nil leaves /oauth/authorize out.
	OAuth *oauth.Server
	// contains filtered or unexported fields
}

Server serves the pages. SSH is nil when the channel is off (session pages are then 404); Auth checks bearer tokens (nil: only signed links open pages); Pages checks the links' signatures and signs the links inside pages (nil: only tokens open pages, and pages link nowhere).

The console needs Store, where its sign-ins are kept: nil leaves it out, and only the pages opened from the chat are served. Config is the configuration Beacon holds (nil: the console's configuration page is empty), Hooks the agent hooks configured, Reporting when each probe location last wrote through the gateway (nil without a gateway), and Version Beacon's own. Branding is what the public pages say of the deployment and of Beacon.

func (*Server) Console

func (s *Server) Console() bool

Console reports whether the console is served (it needs the store for its sign-ins).

func (*Server) Hosts

func (s *Server) Hosts(next http.Handler) http.Handler

Hosts serves a status page's own host name: the page at /, its incidents under /incidents/, its JSON, feed and badges, robots.txt and the static files the page needs; nothing else of Beacon, the console, the API and MCP included, answers there. Other hosts go to next.

func (*Server) Register

func (s *Server) Register(mux *http.ServeMux)

Register adds the pages' routes to mux: GET / is public (home.go), the console is under /console, and the paths the console had before it moved there send people on to their new place.

func (*Server) UpdateSettings

func (s *Server) UpdateSettings(lang i18n.Lang, loc *time.Location, hooks []config.Agent, branding config.Branding)

UpdateSettings updates the web server's live language, timezone, wake hooks and branding without restarting.

Directories

Path Synopsis
Package link signs requests for the alert and session pages people open from chat.
Package link signs requests for the alert and session pages people open from chat.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL