templates

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

Package templates holds the templ components of the Redoubt dashboard. Every dynamic value is rendered through templ's automatic escaping; templ.Raw is never used (user data is never trusted as HTML). Components receive plain view structs from the service layer and never see secret values (golden rule 3): secrets are write-only and only their names are rendered.

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

Index

Constants

This section is empty.

Variables

View Source
var PostureChecklist = []PostureItem{
	{"No shell command strings", "Every Docker operation is a typed call to the Engine API; there is no os/exec anywhere in the control plane.", "TestNoShellExecFromUserInput"},
	{"No raw Docker socket", "Only the socket-proxy holds docker.sock; every call passes an endpoint allow-list that denies exec, privileged and host-affecting endpoints.", "TestNoContainerGetsTheDockerSocket, TestSocketProxyDeniesExec"},
	{"Hardened app containers", "Non-root, no-new-privileges, cap_drop ALL, read-only rootfs with noexec/nosuid tmpfs, seccomp + AppArmor, memory/CPU/pids limits, per-app network.", "TestHardenedHostConfig, TestIntegrationPhase1AllAppContainersHardened"},
	{"Overrides are loud", "Relaxing a default needs an explicit flag, logs a warning and writes an audit event.", "TestHardeningOverrideWarnsAndAudits"},
	{"Write-only secrets", "age-encrypted at rest, injected at runtime, redacted from every log, BuildKit secret mounts only.", "TestSecretsNeverInLogs, TestBuildSecretsNotInImageLayers"},
	{"Tamper-evident audit log", "Every state change is a SHA-256 hash-chained, append-only event; verifiable online and offline.", "TestAuditChainVerifiesAndDetectsTampering, TestEveryStateChangeWritesAuditEvent"},
	{"RBAC in the service layer", "Owner / Admin / Deployer / Viewer checked by every service method, not the router or UI.", "TestRBACEnforcedInServices, TestViewerCannotDeployOrRevealSecrets"},
	{"Dashboard on localhost", "The control plane is published on 127.0.0.1:8443 only; exposure is an explicit operator action.", "TestDashboardBindsLocalhostByDefault"},
	{"Mandatory strong auth", "argon2id passwords, TOTP second factor, lockout and rate limiting.", "TestLoginLockoutAfterFailures, TestRateLimitReturns429"},
	{"Scanned supply chain", "Trivy gate and Syft SBOM per deployment; release artifacts cosign-signed and verified before an update.", "TestCriticalCVEBlocked, TestUpdateVerifiesCosignSignature"},
}

PostureChecklist is the secure-by-default checklist rendered on /security. It mirrors docs/SECURITY.md section 2 and names the test that enforces each line.

View Source
var PostureTSC = []TSCRow{
	{"CC6.1", "Logical access controls", "Role matrix enforced server-side; sessions with TOTP; write-only secrets; every auth and role event on the audit chain (auth.*, user.*)."},
	{"CC6.6 / CC6.7", "Boundary protection, transmission", "Localhost-only control plane, per-app networks, TLS via ACME for every app hostname, socket-proxy allow-list."},
	{"CC7.1 / CC7.2", "Vulnerability and anomaly monitoring", "Trivy scan gate with per-app policy, SBOM per release, self-audit posture checks, lockout and rate-limit audit events."},
	{"CC7.3 / CC7.4", "Evaluation and response", "Hash-chained audit export (JSONL/CSV) with offline verification; failed deployments surface logs without secret values."},
	{"CC8.1", "Change management", "Every deployment, rollback, secret change and configuration change is an audited, attributable event with health-gated cutover."},
	{"A1.2 / A1.3", "Availability, backup and recovery", "Scheduled age-encrypted addon backups to object storage, restore into a fresh addon, Litestream replication of the control-plane database."},
}

PostureTSC is the Trust Services Criteria mapping (evidence-friendly wording only).

Functions

func Account

func Account(p Page) templ.Component

Account shows the signed-in user, second-factor enrolment and API token creation.

func AccountWith

func AccountWith(p Page, totp templ.Component, tokens templ.Component) templ.Component

AccountWith is the Account page with an optional replacement for the #totp and #tokens panels: a plain (non-htmx) form post renders its write-once result inside the full page rather than as a bare fragment, so browsers without JavaScript still get the layout, styles and navigation.

func Alert

func Alert(n Notice) templ.Component

Alert renders a one-shot notice inside a fragment.

func AppDetail

func AppDetail(p Page, app deploy.AppView, deps []deploy.DeploymentView, secrets []deploy.SecretMeta) templ.Component

AppDetail is the per-app page: source, deployments, write-only secrets and actions.

func AppNew

func AppNew(p Page, f AppForm) templ.Component

AppNew is the create-app form.

func AppsList

func AppsList(p Page, rows []AppRow) templ.Component

AppsList shows every app with the hardening verdict of its running container.

func DeploymentPage

func DeploymentPage(p Page, dep deploy.DeploymentView, lines []deploy.LogLine, after int64) templ.Component

DeploymentPage is the log viewer. Persisted (already redacted) lines are rendered server-side; while the deployment is active the htmx SSE extension connects to the JSON API's stream for the rest (app.js appends each line as text, never as HTML) and closes on the "end" event.

func DeploymentStatus

func DeploymentStatus(dep deploy.DeploymentView) templ.Component

DeploymentStatus is the state panel; while active it refreshes when the stream ends and every 10 seconds as a fallback.

func DeploymentsTable

func DeploymentsTable(app string, deps []deploy.DeploymentView, n Notice) templ.Component

DeploymentsTable is the htmx fragment for an app's deployments. While a deployment is active it polls itself every 5 seconds.

func ErrorFragment

func ErrorFragment(msg string) templ.Component

ErrorFragment is the htmx-swapped error (shown inline in the requesting panel).

func ErrorPage

func ErrorPage(p Page, status string, msg string) templ.Component

ErrorPage is the full-page error (403/404/500).

func GitPage

func GitPage(p Page, app deploy.AppView, f GitForm) templ.Component

GitPage is the connect-a-repository form.

func GitResult

func GitResult(p Page, app string, res deploy.GitSourceResult) templ.Component

GitResult shows the webhook secret and deploy key ONCE (they are write-only afterwards).

func Layout

func Layout(p Page) templ.Component

Layout is the shared page shell: strict-CSP-friendly head (no inline scripts, all assets same-origin and content-hashed), navigation and one-shot flash messages.

func Login

func Login(p Page, email string) templ.Component

Login is the email + password form. CSRF for this pre-session form is bound to the redoubt_csrf cookie set alongside the page.

func Posture

func Posture(p Page, rep *selfaudit.Report) templ.Component

Posture renders /security: the checklist, the self-audit score (when the viewer may read it), the TSC mapping, and the honest compliance wording.

func SecretsPanel

func SecretsPanel(p Page, app string, secrets []deploy.SecretMeta, n Notice) templ.Component

SecretsPanel lists secret names (never values) and, for writers, the set/rotate form.

func SelfAudit

func SelfAudit(p Page, rep selfaudit.Report) templ.Component

SelfAudit renders the posture report: score, the items needing attention, then every check.

func Setup

func Setup(p Page, email string) templ.Component

Setup is the first-run owner bootstrap form (shown only while no user exists, D-011).

func TOTPConfirmed

func TOTPConfirmed(codes []string) templ.Component

TOTPConfirmed shows the recovery codes ONCE.

func TOTPEnrolled

func TOTPEnrolled(p Page, secret string, otpauth string) templ.Component

TOTPEnrolled shows the provisioning secret ONCE and asks for the first code.

func TOTPError

func TOTPError(p Page, msg string) templ.Component

TOTPError re-renders the enrolment panel with an error (wrong first code, etc.).

func TOTPLogin

func TOTPLogin(p Page) templ.Component

TOTPLogin asks for the second factor of a pending session.

func TokenCreated

func TokenCreated(p Page, name string, token string) templ.Component

TokenCreated shows a freshly minted API token ONCE.

func TokenForm

func TokenForm(p Page, n Notice) templ.Component

TokenForm is the API-token creation form (rendered inside #tokens).

func TokensFragment

func TokensFragment(p Page, n Notice) templ.Component

TokensFragment re-renders the token panel with a notice (validation errors).

Types

type AppForm

type AppForm struct {
	Name     string
	Hostname string
	Port     string
}

AppForm is the "new app" form state (re-rendered with the user's input on validation errors).

type AppRow

type AppRow struct {
	App    deploy.AppView
	Status *deploy.AppStatus
}

AppRow joins an app record with the live status of its container, if any.

type GitForm

type GitForm struct {
	Provider     string
	RepoURL      string
	Branch       string
	BaseDir      string
	Dockerfile   string
	PollInterval string
}

GitForm is the git-source form state.

type Notice

type Notice struct {
	OK  string
	Err string
}

Notice is a one-shot message rendered inside a fragment.

type Page

type Page struct {
	Title string
	// User is nil when nobody is signed in (login / setup pages).
	User *User
	// CSRF is the anti-forgery token bound to the caller's session (hidden input + hx-headers).
	CSRF string
	// Flash is a one-shot success message; Error a one-shot error message.
	Flash string
	Error string
	// Capabilities derived from the principal's role; the service layer enforces them again.
	CanManage       bool
	CanDeploy       bool
	CanWriteSecrets bool
	CanDelete       bool
	// TOTPEnabled reports whether the signed-in user has a second factor.
	TOTPEnabled bool
}

Page carries the per-request layout state.

type PostureItem

type PostureItem struct {
	Control  string
	Detail   string
	Enforced string // the regression test or mechanism that keeps it true
}

PostureItem is one line of the secure-by-default checklist.

type TSCRow

type TSCRow struct {
	Criteria string
	Topic    string
	Evidence string
}

TSCRow maps a Trust Services Criteria reference to the evidence Redoubt produces for it.

type User

type User struct {
	Email string
	Role  string
}

User is the signed-in principal shown in the navigation.

Jump to

Keyboard shortcuts

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