Expand description
EdgeGuard library surface.
The edgeguard binary (src/main.rs) is a thin CLI on top of this crate. Exposing the
pipeline as a library lets integration tests drive the same build_state /
build_router entry points the binary uses, so tests exercise the real request path
rather than a reimplementation of it.
Re-exports§
pub use crate::auth::hash_password;
Modules§
- acme
- ACME (Let’s Encrypt) automatic certificates via the HTTP-01 challenge, using
instant-acmefor the protocol andrcgenfor the CSR. - auth
- Authentication gates: HTTP Basic, static API-key / bearer-token, and JWT (HS*/RS*/ES*/PS* with either a static key or a fetched, cached JWKS).
- config
- Configuration. Env-first so EdgeGuard drops into any PaaS that injects
$PORTwith zero edits; an optional TOML file layers richer policy on top. - generate
- Static & edge host config generator (Phase 5 / v2.5).
- limiter
- Distributed (shared-store) rate limiting (Phase 4 / v2).
- metrics
- Prometheus metrics, hand-rolled.
- proxy
- Request path: header-size limit -> rate limit (per-IP / per-route) -> auth -> per-key rate limit -> method allowlist -> body-size limit -> WAF input inspection -> forward to upstream. Response path: header injection (incl. CSP / CSP-report-only) -> cookie hardening -> strip leaky headers.
- reload
- Config hot-reload.
- supervisor
- Co-process supervisor.
- tls
- TLS termination via
rustls+tokio-rustls. - waf
- WAF-lite: heuristic input inspection (Phase 4 / v2).
Functions§
- build_
admin_ router - The private/admin router (used in public/private split mode): the internal ops endpoints
(health, readiness, metrics). It has no proxy fallback, so an unknown path returns
404rather than being forwarded upstream. Shares the sameAppStateas the public router, so/__edgeguard/metricsreports the live proxy counters. - build_
public_ router - The public router (used in public/private split mode): the catch-all proxy plus the
browser-facing CSP report sink. The ops endpoints (health/readiness/metrics) are not here
— they live on the private
build_admin_routerlistener, so they aren’t exposed publicly. - build_
router - Build the combined axum
Router: the internal/__edgeguard/*endpoints (health, readiness, Prometheus metrics, CSP report sink) plus the catch-all proxy handler, all on one listener. This is the default (single-port) topology; for the public/private split seebuild_public_router/build_admin_router. Body limits are enforced inside the proxy handler, so the default layer is disabled there; the CSP sink keeps a small explicit cap since it parses the body. - build_
runtime - Build the hot-swappable
Runtimefrom a fully-resolvedConfig: the rate limiters (global per-IP, per-route, per-key), the auth engine, and the parsed size/timeout limits. Errors if any size/rate/auth setting is invalid, so a bad config fails fast — at startup or on reload — rather than per-request. The HTTP client and metric registry live outside the runtime (inAppState) so a reload preserves the connection pool and counters. - build_
state - Build the shared
AppState: a freshRuntimewrapped in anArcSwapfor hot-reload, the upstream HTTP client, and the metric registry.