app

package
v1.76.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package app assembles the Cloudflare module as a process of its own (docs/decisions/0071): the minter of ADR 0070 and its scheduled rotation, with the secrets store, the leases and the audit trail they need, and nothing of the issuer, the directory hub or another provider.

The on-demand exchange (a caller asks the issuer for a token) still calls the minter inside the issuer's process; that path is not here.

Index

Constants

View Source
const HealthPath = modserve.HealthPath

HealthPath answers 200 on the module's listener, for the probes.

View Source
const Interval = time.Minute

Interval is how often the loop looks at the presets. A look at a credential that is not due costs one read of the secrets store and nothing at Cloudflare.

Variables

This section is empty.

Functions

func Mux

func Mux(s *modcall.Server, verify modcall.Verifier, issuers []string) http.Handler

Mux is the module's listener (internal/modserve): the calls at modcall.RPCPath, which verify refuses before they reach a method and which only the issuers' subjects may make, and a health endpoint that needs no credential and tells nothing.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App is the assembled module.

func New

func New(ctx context.Context, cfg Config, log *slog.Logger) (*App, error)

New assembles the module: the ports, the audit trail, the minter.

func (*App) Close

func (a *App) Close() error

Close closes the audit emitter, which delivers what its queue holds within its timeout and drops the rest, and the ports.

func (*App) Flush

func (a *App) Flush(ctx context.Context) error

Flush delivers the audit records still queued: a Lambda function calls it before an invocation returns, since the process is frozen after it.

func (*App) RPC

func (a *App) RPC() *modcall.Server

RPC is the module's server: what a transport of internal/modcall serves.

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run rotates the presets that are due, every Interval, until ctx ends. It first reports the prototypes that are not usable; that is not fatal, since Cloudflare being unreachable must not stop the loop and a mint refuses the same prototype every time.

func (*App) ServeRPC

func (a *App) ServeRPC(ctx context.Context, cfg Config, verify modcall.Verifier) error

ServeRPC answers other modules' calls on the document's address until ctx ends. verify checks the bearer of a call; the document's issuers are the only subjects let in.

func (*App) Tick

func (a *App) Tick(ctx context.Context, target string, unsafeLocal bool) error

Tick runs one preset's rotation once, under its lease, and returns: a credential that is not due costs no call to Cloudflare, and a preset another runner holds is left to it.

func (*App) TickAll added in v1.76.0

func (a *App) TickAll(ctx context.Context) (failed int, summary string, err error)

TickAll is one scheduled pass over every preset, one failure never stopping the others: the {"kind":"cloudflare"} event of the module's Lambda function. It returns the presets that failed, a one-line account (preset=outcome) and the failures joined.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is what the module is made of, built from the service document.

func FromService

func FromService(f *config.Serve, p *config.PolicyDocument) (Config, error)

FromService builds the settings from the documents already read.

func Load

func Load(file string) (Config, error)

Load reads the service document, and the policy document it names if any, and builds the module's settings. A document with no `cloudflare` presets is refused: there is nothing for this module to do.

func (Config) Audience

func (c Config) Audience() string

Audience is the audience a caller's token must have been minted for.

func (Config) LogLevel

func (c Config) LogLevel() slog.Level

LogLevel is the level the process should log at.

func (Config) Serves

func (c Config) Serves() bool

Serves says whether the document makes the module answer other modules.

func (Config) Verify added in v1.76.0

func (c Config) Verify(ctx context.Context, log *slog.Logger) error

Verify builds what New builds: the storage ports, the audit trail's sink and the SSM secrets store the minter credential lives in. It reaches nothing that mutates and mints nothing (adaptercheck).

Jump to

Keyboard shortcuts

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