pub enum RoutePolicy {
Open,
HumanForm,
Signature,
SignedLink,
ApiKey,
}Expand description
How a request to a declared route proves it is legitimate.
The variants are mutually exclusive by construction: a route is protected by a human proof, a machine signature, an artifact this service issued, or nothing — never two of them, and never by whichever check the module happened to wire up.
Variants§
Open
No gateway-level protection. The default, and correct for reads and for anything the handler authenticates itself.
HumanForm
A public form submission from a browser. The handler verifies the
captchaToken the renderer supplies through the Captcha port,
and Harness::build refuses to boot a production venture whose
runtime cannot actually do that (captcha_effective).
Signature
An authenticated machine caller — a provider webhook. The handler
proves the delivery with the module’s declared verifier
(SignatureVerification: Payments::verify_webhook by default,
or a webhook_signature scheme) plus the Inbox dedup ledger. A
CAPTCHA is meaningless here (the caller has no browser) and must
never be rendered or required on such a route.
SignedLink
A public write whose proof is a single-use, purpose-bound
artifact this service issued: a magic link, a passkey or OAuth
challenge, an unsubscribe link (issue #143). The caller presents
something only a prior request of ours could have produced, so the
gate is the Signer key ring (issue #137), not a widget.
This variant exists because the auth login methods had nowhere
honest to sit. They are public writers with no ADR 0010 surface,
so WriteGuards::collect’s conservative fallback filed them
under CAPTCHA — and a passkey challenge will never render one. A
production venture composing only auth modules therefore could not
boot at all except through fz doctor --allow-no-captcha, an
override the code itself documents as previews-only. This is not
an exemption: it carries its own production requirement, a
usable Signer, because without one there is nothing to issue
or verify the artifact with.
ApiKey
An authenticated developer caller (issue #532): the request
presents Authorization: Bearer <api key> and the handler gates
it through require_api_key, which verifies the key’s hash and
checks one scope. A CAPTCHA is meaningless here (the caller is a
machine) and must never be rendered or required on such a route —
the same rule as RoutePolicy::Signature.
This variant carries no scope on purpose: a RoutePolicy is
Copy + serde and travels through surface documents, so it
cannot hold a per-action string. The route policy says how the
route is guarded; the scope is the handler’s per-request argument
to require_api_key.
Implementations§
Source§impl RoutePolicy
impl RoutePolicy
Sourcepub fn is_guarded(self) -> bool
pub fn is_guarded(self) -> bool
Whether this policy is a protection (as opposed to RoutePolicy::Open).
Trait Implementations§
Source§impl Clone for RoutePolicy
impl Clone for RoutePolicy
impl Copy for RoutePolicy
Source§impl Debug for RoutePolicy
impl Debug for RoutePolicy
Source§impl Default for RoutePolicy
impl Default for RoutePolicy
Source§impl<'de> Deserialize<'de> for RoutePolicy
impl<'de> Deserialize<'de> for RoutePolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for RoutePolicy
Source§impl PartialEq for RoutePolicy
impl PartialEq for RoutePolicy
Source§impl Serialize for RoutePolicy
impl Serialize for RoutePolicy
impl StructuralPartialEq for RoutePolicy
Auto Trait Implementations§
impl Freeze for RoutePolicy
impl RefUnwindSafe for RoutePolicy
impl Send for RoutePolicy
impl Sync for RoutePolicy
impl Unpin for RoutePolicy
impl UnsafeUnpin for RoutePolicy
impl UnwindSafe for RoutePolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.