1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! A layer that authenticates requests from Slack.
//!
//! This layer will check the `x-slack-signature` header and the `x-slack-request-timestamp` header
//! to ensure that the request is coming from Slack.
//! If the request is not coming from Slack, this layer will return a 401 Unauthorized response.
//!
//! # Example
//!
//! ```no_run
//! use axum::{routing::get, Router};
//! use slack_auth_middleware::{SlackAuthConfig, SlackAuthLayer};
//! use tracing_subscriber;
//!
//! #[tokio::main]
//! async fn main() {
//! tracing_subscriber::fmt::init();
//!
//! let config = SlackAuthConfig {
//! version_number: "v0".to_string(),
//! slack_signing_secret: "123".to_string(),
//! };
//!
//! let app = Router::new().route("/", get(root).layer(SlackAuthLayer::new(config)));
//! let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
//! axum::serve(listener, app).await.unwrap();
//! }
//!
//! async fn root() -> &'static str {
//! "Hello, World!"
//! }
//! ```
//!
pub use SlackAuthConfig;
pub use SlackAuthLayer;
// exposed, so you can test your API.
pub use SecretSigner;