Crate Layout
The project is organized as a Cargo workspace with libraries (traits and logic) and example runtimes (executable targets).
crates/
├── core/ (multistore) # Runtime-agnostic: traits, S3 parsing, SigV4, registries
├── metering/ (multistore-metering) # Usage metering and quota enforcement middleware
├── sts/ (multistore-sts) # OIDC/STS token exchange (AssumeRoleWithWebIdentity)
└── oidc-provider/ # Outbound OIDC provider (JWT signing, JWKS, exchange)
examples/
├── server/ (multistore-server) # Tokio/Hyper for container deployments
├── lambda/ (multistore-lambda) # AWS Lambda runtime
└── cf-workers/ (multistore-cf-workers) # Cloudflare Workers for edge deploymentsCrate Responsibilities
multistore
The runtime-agnostic core. Contains:
ProxyGateway— Router-based dispatch + S3 parsing + identity resolution + two-phase request dispatch (handle_request()→GatewayResponse)Router— Path-based route matching viamatchitfor efficient pre-dispatchRouteHandlertrait — Pluggable request interceptionMiddlewaretrait — Composable post-auth middleware for dispatch, withafter_dispatchfor post-response observationForwardertrait — Runtime-provided HTTP transport for backend forwarding; the core orchestrates the call so middleware can observe response metadataBucketRegistrytrait — Bucket lookup, authorization, and listingCredentialRegistrytrait — Credential and role storageProxyBackendtrait — Runtime abstraction for store/signer/raw HTTP- S3 request parsing, XML response building, list prefix rewriting
- SigV4 signature verification
- Sealed session token encryption/decryption
- Type definitions (
BucketConfig,RoleConfig,AccessScope, etc.)
Feature flags:
azure— Azure Blob Storage supportgcp— Google Cloud Storage support
multistore-metering
Usage metering and quota enforcement middleware:
MeteringMiddleware<Q, U>— Pre-dispatch quota checking + post-dispatch usage recording via theMiddlewaretraitQuotaCheckertrait — Pre-dispatch quota enforcement; returnErr(QuotaExceeded)to reject with HTTP 429UsageRecordertrait — Post-dispatch operation recording for usage trackingUsageEvent— Operation metadata passed to the recorder (identity, operation, bytes, status)NoopQuotaChecker/NoopRecorder— Convenience no-op implementations for when only one side is needed
multistore-sts
OIDC token exchange implementing AssumeRoleWithWebIdentity:
StsRouterExt— registers a closure that intercepts STS requests on theRouter- JWT decoding and validation (RS256)
- JWKS fetching and caching
- Trust policy evaluation (issuer, audience, subject conditions)
- Temporary credential minting with scope template variables
multistore-oidc-provider
Outbound OIDC identity provider for backend authentication:
OidcRouterExt— registers closures for.well-knowndiscovery endpoints on theRouter- RSA JWT signing (
JwtSigner) - JWKS endpoint serving
- OpenID Connect discovery document
- AWS credential exchange (
AwsBackendAuthmiddleware) - Credential caching
multistore-server
The native server runtime (in examples/server/):
- Tokio/Hyper HTTP server
ServerBackendimplementingProxyBackendwith reqwest- Streaming via hyper
Incomingbodies and reqwestbytes_stream() - Wires
ProxyGatewaywith aRouter(OIDC discovery + STS routes) - CLI argument parsing (
--config,--listen,--domain,--sts-config)
multistore-cf-workers
The Cloudflare Workers WASM runtime (in examples/cf-workers/):
WorkerBackendimplementingProxyBackendwithweb_sys::fetchWorkerForwarderimplementingForwarderwith the Fetch API (zero-copyReadableStream)FetchConnectorbridgingobject_storeHTTP to Workers Fetch APIBandwidthMeterDurable Object — per-(bucket, identity) sliding-window byte counterDoBandwidthMeterimplementingQuotaChecker+UsageRecordervia theBandwidthMeterDOCfRateLimitermiddleware for request-rate limiting via CF Rate Limiting API- Config loading from env vars (
PROXY_CONFIG,BANDWIDTH_QUOTAS)
WARNING
This crate is excluded from the workspace default-members because WASM types are !Send and won't compile on native targets. Always build with --target wasm32-unknown-unknown.
Dependency Flow
Libraries define trait abstractions. Runtimes implement ProxyBackend and Forwarder with platform-native primitives, build a Router with extension traits, and handle the two-variant GatewayResponse.