onboarding

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 16 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 onboarding serves the plain-HTTP onboarding listener: a page that explains how to trust the local CA on each platform, the CA certificate in DER, PEM and iOS profile form, QR codes for this server's HTTPS URLs and invite landing pages. Every other path is redirected to HTTPS. It sets no cookies and exposes no API.

Index

Constants

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

ContentSecurityPolicy of every onboarding response: the page needs only its stylesheet and the QR image, and works without JavaScript.

Variables

This section is empty.

Functions

func IsFirefox

func IsFirefox(ua string) bool

IsFirefox reports whether ua is Firefox, which on Linux keeps its own certificate store.

func New

func New(opts Options) http.Handler

New returns the onboarding handler, wrapped in the LAN guard and the onboarding security headers.

func NewServer

func NewServer(h http.Handler, logger *slog.Logger) *http.Server

NewServer returns the plain-HTTP server for the onboarding handler h.

Types

type OS

type OS string

OS is a device platform the onboarding page has trust steps for.

const (
	OSUnknown OS = ""
	OSiOS     OS = "ios"
	OSAndroid OS = "android"
	OSWindows OS = "windows"
	OSMac     OS = "macos"
	OSLinux   OS = "linux"
)

Platforms with their own trust steps. OSUnknown opens no section.

func DetectOS

func DetectOS(ua string) OS

DetectOS guesses the platform from a User-Agent header. It only chooses which section opens first; every section stays available because the guess can be wrong (iPadOS Safari, for one, reports itself as a Mac).

type Options

type Options struct {
	// InstanceName returns the display name; nil or "" means "bubbles".
	InstanceName func() string
	// CA returns the local CA, or nil when the server uses a
	// bring-your-own certificate (then no CA is offered for download).
	CA func() *tlsca.CA
	// HTTPSPort is the port the HTTPS listener is bound to.
	HTTPSPort int
	// URLs returns this server's HTTPS base URLs, best first, for example
	// "https://192.168.1.20:28225/".
	URLs func() []string
	// Hosts returns the extra host names and addresses this server answers
	// to (its certificate SANs); QR codes are only drawn for these and for
	// the hosts in URLs.
	Hosts func() []string
	// AllowedCIDRs returns extra source ranges admitted besides private and
	// loopback addresses; nil means none.
	AllowedCIDRs func() []netip.Prefix
	// Logger receives template errors; nil discards them.
	Logger *slog.Logger
}

Options configure the onboarding handler.

Jump to

Keyboard shortcuts

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