Documentation
¶
Overview ¶
Package web is the admin panel: server-rendered html/template pages with htmx partial swaps, session cookie auth, per-request CSRF tokens, and a strict content security policy. Handlers call domain services directly — the REST API is never in the request path (docs/architecture/ project-structure.md: api/web → services).
Security posture (docs/operations/security.md): session tokens are hashed at rest by internal/auth; the CSRF token is HMAC-derived from the session token so it needs no storage; scripts/styles are same-origin only (no inline script/style survive CSP); secrets never reach templates.
Index ¶
- type Deps
- type ReleaseCatalog
- type Server
- type View
- func (v *View) A(name string) string
- func (v *View) B(n int64) string
- func (v *View) BLim(limit *int64) string
- func (v *View) BLimParts(limit *int64) byteParts
- func (v *View) BParts(n int64) byteParts
- func (v *View) Can(scope string) bool
- func (v *View) CompactAuditID(value string) string
- func (v *View) D(t *time.Time) string
- func (v *View) DT(t *time.Time) string
- func (v *View) DateTime(t time.Time) string
- func (v *View) DeliveryError(message string) string
- func (v *View) Dur(sec int64) string
- func (v *View) DurLim(sec *int64) string
- func (v *View) DurUnit(secs *int64) string
- func (v *View) DurVal(secs *int64) string
- func (v *View) Elapsed(start, end time.Time) string
- func (v *View) ExpiryClass(t *time.Time) string
- func (v *View) HasChoice(values []string, value string) bool
- func (v *View) Human(text string) string
- func (v *View) Icon(name string) template.HTML
- func (v *View) IconS(name string) template.HTML
- func (v *View) Initial(name string) string
- func (v *View) IsActive(section string) bool
- func (v *View) KD(n *int) string
- func (v *View) LocaleLink() string
- func (v *View) MeterClass(used int64, limit *int64) string
- func (v *View) N(n int64) string
- func (v *View) OpsLabel(kind, value string) string
- func (v *View) OpsTimestamp(t time.Time) string
- func (v *View) QuotaUnit(b *int64) string
- func (v *View) QuotaVal(b *int64) string
- func (v *View) Rel(t *time.Time) string
- func (v *View) RelIn(t *time.Time) string
- func (v *View) ScopeDescription(value string) string
- func (v *View) ScopeLabel(value string) string
- func (v *View) ScopePresetTier(scope string) string
- func (v *View) St(status string) string
- func (v *View) StClass(status string) string
- func (v *View) StatusTone(state nodestatus.State) string
- func (v *View) T(key string, args ...any) string
- func (v *View) TokenExpired(t *time.Time) bool
- func (v *View) U(n *int) string
- func (v *View) UnknownChoices(values []string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
DB *database.DB
Sessions *auth.SessionStore
Admins *admin.Service
Resellers *reseller.Service
Settings *settings.Registry
Ring *secrets.KeyRing
Audit *audit.Service
Users *user.Service
Devices *device.Service
Plans *plan.Service
Integration *integration.Service
Ifaces *iface.Service
// ProfileGenerator is the canonical server-side profile preview seam.
// It defaults to Ifaces.GenerateProfile; tests may replace it to exercise
// entropy failures without weakening the production generator.
ProfileGenerator func(iface.ProfilePolicy) (iface.Obfuscation, error)
Accounting *accounting.Service
Log *slog.Logger
// Reconciler runs the complete serialized network pass after structural
// mutations (see api.Server).
Reconciler accounting.Reconciler
NodeStatus func(context.Context, time.Time) nodestatus.Snapshot
// ClientConf renders client configs + QR (shared with the REST API).
ClientConf *clientconf.Renderer
// Links serves the per-user subscription links (public /sub/ surface).
Links *subscription.Service
// Backup is the archive engine (panel + CLI only — ADR-0007). Wired
// from serve; nil in tests that don't exercise the ops screens.
Backup *backup.Service
// UpdateQueue is the data-volume side of the fixed host-owned lifecycle
// broker. UpdateCatalog supplies published stable versions on demand.
UpdateQueue *updatequeue.Queue
UpdateCatalog ReleaseCatalog
DomainQueue *domainqueue.Queue
DomainPolicy domaintls.Snapshot
// Tokens and Webhooks are the same instances the REST API uses — one
// business layer, two surfaces.
Tokens *token.Service
Webhooks *webhook.Service
// Telemetry is the scheduler-owned immutable live history. Dashboard
// requests never invoke its source.
Telemetry *telemetry.Sampler
Version string
TLSMode config.TLSMode
NodeID string
ToolsVersion string
}
Deps wires the services the panel renders. The same instances the REST API uses are passed in — one business layer, two surfaces.
type ReleaseCatalog ¶
type ReleaseCatalog interface {
Releases(context.Context) ([]distribution.Release, error)
}
type Server ¶
type Server struct {
Deps
// contains filtered or unexported fields
}
Server is the admin panel.
type View ¶
type View struct {
Locale i18n.Locale
Dir string
Theme string // "light" | "dark" | "system"
Preset string // allowlisted visual preset ID; empty/unknown resolves to built-in
Digits i18n.DigitStyle
Path string // request path, for nav highlighting
PageClass string // content width tier (" content--narrow" on form/settings routes)
SubLayout string // public subscription composition, absent on error surfaces
Admin *auth.Admin
CSRF string
Version string
UpdateNotice bool
LoginContext url.Values
// ToastMsg carries a post-redirect-flash message (already localized).
ToastMsg string
ToastError bool
// Data carries the page-specific payload (typed per page).
Data any
// contains filtered or unexported fields
}
View is the render context for every template execution. Locale-scoped helpers are methods so templates stay i18n-aware without global state.
func (*View) A ¶
A returns the cache-busted URL for an embedded static asset, e.g. {{.A "/css/app.css"}}.
func (*View) BParts ¶ added in v0.1.1
BParts keeps a Latin numeral and its localized unit as separate visual atoms. This lets an RTL flex row preserve natural number → unit order.
func (*View) Can ¶
Can reports whether the signed-in admin may use a scope-gated surface (owners always pass). The nav renders accordingly; the server enforces regardless (security.md: the UI never hides what the server doesn't enforce — this is the polite direction, not the security one).
func (*View) CompactAuditID ¶
CompactAuditID shortens UUID-shaped identifiers only. Human names, addresses and other meaningful target values retain their exact presentation.
func (*View) DeliveryError ¶
func (*View) DurLim ¶ added in v0.1.4
DurLim renders a stored optional duration for template previews.
func (*View) DurVal ¶
DurVal renders a duration for a value+unit form input: whole months when the duration is a multiple of 30 days, else whole days, else hours.
func (*View) ExpiryClass ¶
ExpiryClass colors imminent (warn) and passed (danger) expiries.
func (*View) Human ¶ added in v0.1.8
Human formats a previously humanized metric or date string. Machine values and input values use their original typed fields, never this display helper.
func (*View) Icon ¶
Icon renders a sprite reference. Icons are recognition aids, never decoration; text labels stay in markup next to them.
func (*View) LocaleLink ¶
func (*View) MeterClass ¶
MeterClass picks the nearest width step (CSP forbids inline styles) and the tone class for a used/limit pair; limit == nil renders full bar.
func (*View) QuotaVal ¶
QuotaVal renders a byte limit as a decimal number for a form input, choosing the more readable unit: MB below 1 GB, GB otherwise. nil = "".
func (*View) RelIn ¶
RelIn renders a future-relative hint ("in 3 days") for expiry columns; past dates fall back to the past-relative form.
func (*View) ScopeDescription ¶
func (*View) ScopeLabel ¶
func (*View) ScopePresetTier ¶ added in v0.1.4
func (*View) StatusTone ¶ added in v0.1.10
func (v *View) StatusTone(state nodestatus.State) string
func (*View) UnknownChoices ¶
Source Files
¶
- appearance.go
- auth.go
- backups.go
- backups_restore.go
- backups_schedules.go
- cleanup.go
- dashboard.go
- dashboard_telemetry.go
- devices.go
- domains.go
- ifaces.go
- middleware.go
- operational_forms.go
- ops_admins.go
- ops_audit.go
- ops_labels.go
- ops_resellers.go
- ops_tokens.go
- ops_webhooks.go
- parse.go
- plans.go
- pool_editor.go
- render.go
- reseller_tokens.go
- reseller_users.go
- scope_presets.go
- settings.go
- sparkline.go
- sub.go
- surface_errors.go
- svgchart.go
- system.go
- update_actions.go
- update_catalog.go
- update_view.go
- updates.go
- users.go
- visual_presets.go
- web.go