Skip to main content

SagaHttpReplayGuard

Struct SagaHttpReplayGuard 

Source
pub struct SagaHttpReplayGuard { /* private fields */ }
Expand description

业务作用:在 HMAC 时间窗内原子拒绝已经验真的 nonce,防止认证请求被原样重放。

本结构有意使用有界内存:过期项在每次 claim 前清理,未过期项达到上限时 fail-closed,绝不 淘汰仍可重放的证据。它保护单进程 connector;多副本生产入口必须把 nonce claim 放入共享的 强一致存储,或由网关提供等价的一次性请求语义。

Implementations§

Source§

impl SagaHttpReplayGuard

Source

pub fn new(max_entries: usize) -> Result<Self, SagaHttpMessageAuthError>

业务作用:构造有界 replay guard,限制攻击流量可占用的 nonce 记录数。

参数说明:

  • max_entries: 同一进程允许保留的未过期 nonce 上限,必须大于零。

返回:上限合法时返回空 guard;零容量直接拒绝启动。

Source

pub fn verify_once( &self, authenticator: &SagaHttpMessageAuthenticator, message: &SagaHttpSignedMessage<'_>, now_ms: u64, ) -> Result<(), SagaHttpMessageAuthError>

业务作用:先校验完整 HMAC,再原子占用 producer/nonce,形成仅可消费一次的身份凭据。

参数说明:

  • authenticator: 当前部署信任边绑定的 HMAC 认证器。
  • message: 冻结 producer/path/timestamp/nonce/body/signature 的原始收据。
  • now_ms: 接收端当前 Unix 毫秒。

返回:签名有效且 nonce 首次出现时成功;重放、容量耗尽或认证失败均脱敏拒绝。

Source

pub fn metrics(&self, now_ms: u64) -> SagaHttpReplayMetrics

业务作用:读取并顺带清理一条信任边的 replay 防护指标,供控制面区分攻击与容量不足。

参数说明:

  • now_ms: 指标采集时钟,用于剔除已经越过 replay horizon 的 active claim。

返回:不含 producer、nonce、path 或 payload 的低基数计数快照。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more