pub struct RequestSign { /* private fields */ }Expand description
Query/body signing helper. 查询串/表单体签名。
Implementations§
Source§impl RequestSign
impl RequestSign
Sourcepub fn new(secret: impl Into<String>, window_secs: i64) -> Self
pub fn new(secret: impl Into<String>, window_secs: i64) -> Self
Create a signer with secret and timestamp window (seconds). 使用密钥与时间窗(秒)创建签名器。
Sourcepub fn with_dao(self, dao: Arc<SaTokenDao>) -> Self
pub fn with_dao(self, dao: Arc<SaTokenDao>) -> Self
Attach Dao so nonce values can be consumed once. 挂载 Dao,使 nonce 只能使用一次。
Sourcepub fn sign_params(
&self,
params: &BTreeMap<String, String>,
) -> SaTokenResult<String>
pub fn sign_params( &self, params: &BTreeMap<String, String>, ) -> SaTokenResult<String>
Hex HMAC-SHA256 over the canonical query (excludes the sign field).
对规范查询串做 Hex HMAC-SHA256(排除 sign 字段)。
Sourcepub fn create_signed(
&self,
params: BTreeMap<String, String>,
) -> SaTokenResult<BTreeMap<String, String>>
pub fn create_signed( &self, params: BTreeMap<String, String>, ) -> SaTokenResult<BTreeMap<String, String>>
Insert timestamp + nonce then compute sign. Caller sends the whole map.
写入 timestamp 与 nonce 再计算 sign。调用方发送完整 map。
Sourcepub async fn verify_params(
&self,
params: &BTreeMap<String, String>,
provided_sign: &str,
) -> SaTokenResult<()>
pub async fn verify_params( &self, params: &BTreeMap<String, String>, provided_sign: &str, ) -> SaTokenResult<()>
Verify signature, timestamp window, and optional nonce uniqueness. 校验签名、时间窗与可选 nonce 唯一性。
Trait Implementations§
Source§impl Clone for RequestSign
impl Clone for RequestSign
Source§fn clone(&self) -> RequestSign
fn clone(&self) -> RequestSign
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RequestSign
impl !UnwindSafe for RequestSign
impl Freeze for RequestSign
impl Send for RequestSign
impl Sync for RequestSign
impl Unpin for RequestSign
impl UnsafeUnpin for RequestSign
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
Mutably borrows from an owned value. Read more