web

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 55 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)
	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 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
	// 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
}

AppDeps are the services of the real UI.

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.

Directories

Path Synopsis
templ: version: v0.3.1070
templ: version: v0.3.1070
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.
templ: version: v0.3.1070
templ: version: v0.3.1070
pages
admin
templ: version: v0.3.1070
templ: version: v0.3.1070
authorities
templ: version: v0.3.1070
templ: version: v0.3.1070
certificates
templ: version: v0.3.1070
templ: version: v0.3.1070
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).
overview
templ: version: v0.3.1070
templ: version: v0.3.1070
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