pub struct SlackHTTPVerifier { /* private fields */ }Expand description
Verifies Slack http requests are signed by the given secret.
A convenience wrapper around SlackVerifier.
Implementations§
Source§impl SlackHTTPVerifier
impl SlackHTTPVerifier
Sourcepub fn new<S: AsRef<[u8]>>(secret: S) -> Result<Self, InvalidKeyLengthError>
pub fn new<S: AsRef<[u8]>>(secret: S) -> Result<Self, InvalidKeyLengthError>
Returns a new SlackHTTPVerifier.
ⓘ
let verifier = SlackHTTPVerifier::new("8f742231b10e8888abcd99yyyzzz85a5").unwrap();Sourcepub fn verify<'a, R>(&self, req: &'a R) -> Result<(), VerificationError>where
R: HTTPRequest<'a>,
pub fn verify<'a, R>(&self, req: &'a R) -> Result<(), VerificationError>where
R: HTTPRequest<'a>,
Verifies the given request.
ⓘ
let slack_sample_timestamp: &str = "1531420618";
let slack_sample_sig: &str =
"v0=a2114d57b48eac39b9ad189dd8316235a7b4a8d21a10bd27519666489c69b503";
let slack_sample_body: &str = // ...
let verifier = SlackHTTPVerifier::new("8f742231b10e8888abcd99yyyzzz85a5").unwrap();
let req = http::Request::builder()
.header("X-Slack-Request-Timestamp", slack_sample_timestamp)
.header("X-Slack-Signature", slack_sample_sig)
.body(slack_sample_body)
.unwrap();
assert!(verifier.verify(&req).is_ok())Trait Implementations§
Source§impl Clone for SlackHTTPVerifier
impl Clone for SlackHTTPVerifier
Source§fn clone(&self) -> SlackHTTPVerifier
fn clone(&self) -> SlackHTTPVerifier
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SlackHTTPVerifier
impl Debug for SlackHTTPVerifier
impl Send for SlackHTTPVerifier
impl Sync for SlackHTTPVerifier
Auto Trait Implementations§
impl Freeze for SlackHTTPVerifier
impl RefUnwindSafe for SlackHTTPVerifier
impl Unpin for SlackHTTPVerifier
impl UnwindSafe for SlackHTTPVerifier
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