Skip to content

Report geo on every adapter and bind Axum geo from the manifest - #502

Open
dhruv8sh wants to merge 2 commits into
feature/pluggable-geo-providersfrom
spec/482-axum-geo-manifest-binding
Open

dhruv8sh wants to merge 2 commits into
feature/pluggable-geo-providersfrom
spec/482-axum-geo-manifest-binding

Conversation

@dhruv8sh

Copy link
Copy Markdown
Collaborator

Summary

  • ctx.geo() now reports country and region on Fastly (geo_lookup for the client address) and Cloudflare (the request's cf metadata), always on, so applications such as Trusted Server no longer need platform-specific geo code (EZI-4, EZI-4c).
  • Axum's CloudFront geo from Add pluggable native Geo providers and protected CloudFront ingress #439 can be selected by [adapters.axum.geo] in edgezero.toml, with every key overridable by EDGEZERO__ADAPTER__GEO__* at startup. This replaces Trusted Server's TS_NATIVE_GEO_PROFILE boot profile (EZI-4a); deploy-time values such as ALB networks stay out of the compiled manifest.
  • Stacked on Add pluggable native Geo providers and protected CloudFront ingress #439 (feature/pluggable-geo-providers) because main has no geo code yet. Spin (EZI-4s) follows separately.

Changes

Crate / File Change
edgezero-core/src/geo.rs GeoSource::{Fastly, Cloudflare}, GeoTrustBasis::PlatformMetadata, both enums #[non_exhaustive]; reserved fastly/cloudflare provider IDs; GeoOutcome::platform() treats unusable platform values (e.g. Cloudflare XX/T1) as missing metadata, not a forged assertion
edgezero-core/src/manifest.rs Optional [adapters.axum.geo] table (provider, alb_peer_cidrs, origin_credential_header_name); rejects provider = "off" with policy fields and the table on non-Axum adapters
edgezero-adapter-fastly/src/request.rs Looks up geo before the prepare hook and dispatches with dispatch_admitted_with_geo
edgezero-adapter-cloudflare/src/request.rs Reads cf.country / cf.regionCode and dispatches with dispatch_admitted_with_geo
edgezero-adapter-axum/src/geo.rs, run_options.rs, dev_server.rs Resolver with precedence with_geo → settings → manifest → off; misconfiguration fails before listening; dev run_app reads settings only; geo_capability() stays explicit-only, new geo_capability_for::<A>() reports the runner's selection; shared geo setting-name list
Tests Viceroy-backed Fastly lookup (loopback → US/CA), Cloudflare dispatch with cf metadata, Axum precedence/rejection units, end-to-end manifest + settings hosting test, dev-runner test, baked-manifest round trip; #439 contract tests updated for always-on platform geo
docs/guide/native-geo.md, configuration.md, adapters/axum.md Manifest and settings selection, precedence, validation

Closes

Part of #482 (Fastly, Cloudflare and Axum). Spin (EZI-4s) remains, so this does not close the issue.

Test plan

  • cargo test --workspace --all-targets (2921 passed)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings (pinned 1.98.1)
  • cargo fmt --all -- --check
  • cargo check --workspace --all-targets --features "fastly cloudflare spin"
  • WASM builds: wasm32-wasip1 (Fastly) / wasm32-wasip2 (Spin) / wasm32-unknown-unknown (Cloudflare)
  • examples/app-demo workspace: cd examples/app-demo && cargo test --workspace --all-targets
  • Docs: Prettier on changed pages
  • Manual testing via edgezero serve --adapter axum
  • Other: Fastly lib geo test and 37 contract tests under Viceroy; Cloudflare 141 lib + 31 contract tests under wasm-bindgen; Axum production_hosting geo tests with and without geo-cloudfront; Axum doc tests

Local Viceroy 0.21.1 aborts some Fastly outbound backend tests (e.g. configured_connect_timeout_reads_registered_sdk_timeout_settings) on unmodified #439 as well; CI's patched Viceroy is the reference.

Checklist

  • Changes follow CLAUDE.md conventions
  • No Tokio deps added to core or adapter crates
  • Route params use {id} syntax (not :id)
  • Types imported from edgezero_core (not http crate)
  • Store wiring goes through KvRegistry / ConfigRegistry / SecretRegistry (not the legacy single-handle setters) — see spec §6.6
  • New code has tests
  • No secrets or credentials committed

Fastly reads geo_lookup for the client address and Cloudflare reads the
request's cf metadata. Both are always selected and pass their outcome
through dispatch_admitted_with_geo, so public extensions still cannot
replace it. Platform values that fail validation, such as Cloudflare's XX
and T1 placeholders, report missing metadata rather than an invalid
assertion. GeoSource and GeoTrustBasis gain platform variants and become
non_exhaustive; fastly and cloudflare are reserved provider IDs.
[adapters.axum.geo] carries provider, alb_peer_cidrs and
origin_credential_header_name defaults, each overridden by the matching
EDGEZERO__ADAPTER__GEO__* setting. Precedence is with_geo, then settings,
then the manifest, then off, and misconfiguration fails startup instead of
falling back. The dev run_app reads settings only. geo_capability() stays
explicit-only and geo_capability_for::<A>() reports the runner's view.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant