Documentation
¶
Overview ¶
Package api is fleetwire's HTTP API: the tenant and operator API on the public listener, and enrollment and renewal on the device listener.
Routing uses the standard library's method patterns (ADR-0011). Every error is an RFC 9457 problem; every list is paged with signed cursors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
PublicAddr string
DeviceAddr string
PublicTLS *tls.Config
// DeviceTLS must request (not require) client certificates: enrollment
// has none yet, renewal needs one.
DeviceTLS *tls.Config
// CABundlePEM is what devices trust for the broker and the API.
CABundlePEM []byte
BrokerURL string
DeviceAPIURL string
RatePerSecond float64
RateBurst int
// AuthFailPerSecond and AuthFailBurst bound failed token lookups per
// client network. A network over the budget is refused before its
// tokens reach the database.
AuthFailPerSecond float64
AuthFailBurst int
// EnrollPerSecond and EnrollBurst limit enrollment and CRL requests
// per client network.
EnrollPerSecond float64
EnrollBurst int
EnrollTokenTTL time.Duration
ExportDir string
// MaxActiveExports caps a tenant's pending and running exports.
MaxActiveExports int
// ReadingsScanChunks is the most chunks one readings page decrypts
// (default 2000).
ReadingsScanChunks int
}
Config is the API's own settings.
type Deps ¶
type Deps struct {
DB *store.DB
Keyring keyring.Keyring
Keys *tenantkey.Manager
DeviceCA *pki.CA
CRL *crl.Publisher
CursorKey []byte
Log *slog.Logger
Registry prometheus.Registerer
}
Deps are the API's collaborators.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves the API.
func (*Server) DeviceHandler ¶
DeviceHandler serves enrollment and renewal.
func (*Server) PublicHandler ¶
PublicHandler serves the tenant and operator API.
func (*Server) Serve ¶
Serve runs both listeners until ctx ends, then shuts down gracefully. untilDrained run until both listeners have drained, as the token use recorder does, so work a request still running at shutdown hands over to them is still done: the API passes the CRL publisher, which must publish a revocation made by such a request. Serve returns once they stopped.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apitest runs a real fleetwire API for tests: real PostgreSQL, the real dev PKI, real TLS listeners, and the real job worker.
|
Package apitest runs a real fleetwire API for tests: real PostgreSQL, the real dev PKI, real TLS listeners, and the real job worker. |