profile

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 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 profile turns example command-line flags into the matched pair purser hands out: a *tls.Config and, on the server side, the authenticator that understands the connections it admits.

Both mTLS profiles are wired here, in one place, so the difference between them is a diff rather than two files a reader has to hold in their head at once. The server and client binaries are then identical across profiles: they take a config, listen or dial, and never learn which profile they are running.

Nothing here is part of purser's exported API.

Index

Constants

View Source
const (
	PKI    = "pki"
	SPIFFE = "spiffe"
)

Profile names an mTLS profile.

Variables

View Source
var ALPN = []string{"h2", "http/1.1"}

ALPN is what both ends offer. Set explicitly rather than left to crypto/tls so the examples negotiate HTTP/2, which is what a service-to-service caller wants and what client.Transport exists to preserve.

Functions

This section is empty.

Types

type Closer

type Closer func() error

Closer releases whatever the config holds open — a reloading credential source, in the SPIFFE case. Never nil.

type Flags

type Flags struct {

	// Profile selects the mTLS profile: PKI or SPIFFE.
	Profile string

	// PKI profile.
	PKICert    string
	PKIKey     string
	PKIPeerCA  string
	PKISubject string
	PKIAdmitOU string
	PKIReload  time.Duration

	// SPIFFE profile.
	SPIFFEDir         string
	SPIFFETrustDomain string
	SPIFFEReload      time.Duration
	SPIFFEIDs         stringList
	SPIFFEGKE         stringList
	// contains filtered or unexported fields
}

Flags is the credential configuration shared by the example server and client.

func (*Flags) Client

func (f *Flags) Client(log *slog.Logger) (*tls.Config, Closer, error)

Client builds the dialling config.

There is no authenticator half here: a client verifies the server during the handshake and has no inbound request to name.

func (*Flags) Register

func (f *Flags) Register(fs *flag.FlagSet, role Role)

Register declares the flags for role on fs.

func (*Flags) Server

func (f *Flags) Server(log *slog.Logger) (*tls.Config, authn.Authenticator, Closer, error)

Server builds the listener config and the authenticator that reads callers off the connections it admits.

The two are returned together because purser returns them together: the profiles verify with opposite crypto/tls idioms, and an authenticator paired with the wrong listener reads the wrong field.

type Role

type Role int

Role is which end of the connection the flags are being registered for. The two ends take different flags — a server has an identity source to read callers from, a client has a server to authorize — and registering only what applies keeps a flag that silently does nothing off the help text.

const (
	RoleServer Role = iota
	RoleClient
)

The two roles.

Jump to

Keyboard shortcuts

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