web

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 71 Imported by: 0

Documentation

Overview

Package web serves the admin UI: templ pages, the embedded static assets and the security headers every response gets.

Phase 0: the component gallery (/design) and, in dev mode only, the UI prototype on fixture data (prototype*.go).

Index

Constants

View Source
const ContentSecurityPolicy = "default-src 'self'; script-src 'self'; style-src 'self'; " +
	"img-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'"

ContentSecurityPolicy is sent with every response (security.md). No inline scripts or styles are possible – templates may only use the global classes.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(opts Options) (http.Handler, error)

NewHandler returns the admin UI handler with all routes and middleware.

func SecurityHeaders

func SecurityHeaders(next http.Handler) http.Handler

SecurityHeaders sets the headers of every admin response (security.md "Transport and headers"); the server adds HSTS on the TLS listener.

Types

type ACMEAdmin added in v0.2.0

type ACMEAdmin interface {
	// Waiting counts orders whose certificate waits for the unseal.
	Waiting(ctx context.Context) (int64, error)
	// Pending counts accounts and names that wait for an admin.
	Pending(ctx context.Context) (accounts, names int64, err error)
	Accounts(ctx context.Context, who keys.Who) ([]acme.AccountInfo, error)
	Account(ctx context.Context, who keys.Who, id string) (*acme.AccountInfo, error)
	SetAccountPredecessor(ctx context.Context, id string, policy *predecessor.Policy, who keys.Who) error
	ApproveAccount(ctx context.Context, id string, who keys.Who) error
	Names(ctx context.Context, who keys.Who) ([]acme.NameInfo, error)
	DecideName(ctx context.Context, name string, approve bool, who keys.Who) error
	Orders(ctx context.Context, who keys.Who) ([]acme.OrderInfo, error)
	EABKeys(ctx context.Context, who keys.Who) ([]acme.EABKeyInfo, error)
	CreateEABKey(ctx context.Context, label string, days int, who keys.Who) (*acme.NewEABKey, error)
}

ACMEAdmin is what the UI uses of the ACME server.

type AlertSource added in v0.3.3

type AlertSource interface {
	List(ctx context.Context, who keys.Who, now time.Time) (open, resolved []monitor.Alert, err error)
}

AlertSource is what the UI reads of the monitoring: the open alerts and those resolved in the last 7 days, if who may read them.

type AnalysisSource added in v0.3.8

type AnalysisSource interface {
	Get(ctx context.Context, who keys.Who) (*analysis.Analysis, error)
}

AnalysisSource is what the UI reads of the analysis (v0.3.8): the findings and the state of the ten rules, if who passes the tenant-wide authz.ReadPKI check. The service keeps the result for a minute; it is shared, never change it.

type AppDeps

type AppDeps struct {
	Auth    *auth.Service
	Engine  *ca.Engine
	Keys    *keys.Keyring
	Presets *preset.Set
	Clock   clock.Clock
	// TrustedProxies may set X-Forwarded-For (auth.trusted_proxies).
	TrustedProxies []netip.Prefix
	Demo           bool
	Tenant         string // the tenant of this instance (phase 1: one)
	// Settings, TenantAudit and InstanceAudit serve the pages of step 19
	// (tenant settings, audit log); nil hides those pages.
	Settings                   *tenant.Store
	TenantAudit, InstanceAudit *sql.DB
	// Agents is the agent service (v0.3); nil while agent.base_url is empty.
	Agents *agents.Service
	// AgentDist, AgentBaseURL and AgentTLSIssuer drive guided installation.
	AgentDist      *agentdist.Store
	AgentBaseURL   string
	AgentTLSIssuer string
	ServerVersion  string
	// ACME is the ACME server (PHASE2); nil while ACME is off.
	ACME ACMEAdmin
	// ACMEDirectory is the directory URL clients use (shown with EAB keys).
	ACMEDirectory string
	// ServerAttention reports the state of the server itself for the
	// dashboard: the certificates it issues for its listeners
	// (admin.tls_issuer, acme.tls_issuer) and the scheduled backups; nil =
	// nothing to report.
	ServerAttention func(sealed bool) []view.Message
	// Alerts are the open alerts of the monitoring (v0.3.3); nil hides them.
	Alerts AlertSource
	// Notifier tests the notification channels (v0.3.3); nil hides the button.
	Notifier NotifyTester
	// Endpoints are the TLS scan endpoints (v0.3.4); nil hides the page.
	Endpoints EndpointAdmin
	// Reports and Analysis are the report and analysis services (v0.3.8);
	// nil hides the pages and the dashboard charts.
	Reports  ReportSource
	Analysis AnalysisSource
}

AppDeps are the services of the real UI.

type EndpointAdmin added in v0.3.4

type EndpointAdmin interface {
	List(ctx context.Context, who keys.Who) ([]monitor.EndpointState, error)
	Create(ctx context.Context, who keys.Who, req tlsscan.Request) (*tlsscan.Endpoint, error)
	Delete(ctx context.Context, who keys.Who, id string) error
	ScanNow(ctx context.Context, who keys.Who, id string) error
	// Settings are the monitor.scan_* keys: the ports, the limit, off.
	Settings() tlsscan.Settings
}

EndpointAdmin is what the UI uses of the TLS scan: the endpoints with their assessed state, and the actions. The service checks the roles and writes the audit entries.

type NotifyTester added in v0.3.3

type NotifyTester interface {
	Names() []string
	Send(ctx context.Context, who keys.Who) ([]notify.Result, error)
}

NotifyTester sends the test message through the configured channels (the service checks the role and audits it).

type Options

type Options struct {
	// Dev shows the DEV MODE banner on every page and enables the UI
	// prototype on fixture data.
	Dev    bool
	Logger *slog.Logger
	// App, if set, serves the real UI on the services (phase 1 step 14)
	// instead of the gallery; Dev and App are exclusive.
	App *AppDeps
}

Options configure the handler.

type ReportSource added in v0.3.8

type ReportSource interface {
	Get(ctx context.Context, who keys.Who) (*report.Report, error)
}

ReportSource is what the UI reads of the reports (v0.3.8): the five chart datasets of the tenant, if who passes the tenant-wide authz.ReadPKI check. The service keeps them for a minute; the report is shared, never change it.

Directories

Path Synopsis
Package charts turns the datasets of internal/report into the plain chart descriptions that components.Chart draws (docs/PHASE3.md section 14).
Package charts turns the datasets of internal/report into the plain chart descriptions that components.Chart draws (docs/PHASE3.md section 14).
Package fixture provides fixed sample data for the UI prototype in dev mode.
Package fixture provides fixed sample data for the UI prototype in dev mode.
pages
design
Package design renders the component gallery at /design: every CSS class of web/styles is shown with realistic sample data (frontend.md).
Package design renders the component gallery at /design: every CSS class of web/styles is shown with realistic sample data (frontend.md).
Package view holds the types shared by the shell, components and pages: page metadata, the user's appearance preferences, status values and date formatting.
Package view holds the types shared by the shell, components and pages: page metadata, the user's appearance preferences, status values and date formatting.

Jump to

Keyboard shortcuts

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