diff options
-rw-r--r-- | Cargo.toml | 10 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | src/lib.rs | 7 | ||||
-rw-r--r-- | src/security.rs | 4 | ||||
-rw-r--r-- | src/security/signed.rs (renamed from src/signed.rs) | 0 |
5 files changed, 18 insertions, 11 deletions
@@ -14,18 +14,15 @@ keywords = ["web", "cookie", "hyper", "hmac"] [features] hyper_body = ["hyper", "async-trait"] hyper_body_json = ["serde_json", "hyper_body"] +security = ["base64", "hmac", "rand", "sha2"] [dependencies] http = "0.2" cookie = { version = "0.15", features = ["percent-encode"] } serde = { version = "1.0", features = ["derive"] } serde_urlencoded = "0.7.0" -base64 = "0.13" -hmac = "0.10" httpdate = "0.3.2" mime = "0.3" -rand = "0.8" -sha2 = "0.9" time = "0.2" thiserror = "1.0" @@ -33,6 +30,11 @@ hyper = { version = "0.14", optional = true } async-trait = { version = "0.1", optional = true } serde_json = { version = "1.0", optional = true } +base64 = { version = "0.13", optional = true } +hmac = { version = "0.10", optional = true } +rand = { version = "0.8", optional = true } +sha2 = { version = "0.9", optional = true } + [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"]
\ No newline at end of file @@ -12,10 +12,10 @@ with [Serde](https://serde.rs/) you can enable the following feature flags: `into_form` method for parsing data submitted from HTML forms. - `hyper_body_json` additionaly provides an `into_json` method -Furthermore Sputnik provides what's necessary to implement [signed & expiring -cookies](#signed--expiring-cookies) with the expiry date encoded into the -signed cookie value, providing a more lightweight alternative to JWT if you -don't need interoperability. +With the `security` feature Sputnik furthermore provides what's necessary to +implement [signed & expiring cookies](#signed--expiring-cookies) with the +expiry date encoded into the signed cookie value, providing a more +lightweight alternative to JWT if you don't need interoperability. Sputnik does **not** handle routing because even complex routing can be quite easily implemented with nested `match` blocks. If you want a more high-level @@ -6,10 +6,13 @@ pub use mime; pub use httpdate; -pub mod security; pub mod request; pub mod response; -mod signed; + +#[cfg(feature="security")] +#[cfg_attr(docsrs, doc(cfg(feature = "security")))] +pub mod security; + #[cfg(feature="hyper_body")] #[cfg_attr(docsrs, doc(cfg(feature = "hyper_body")))] pub mod hyper_body; diff --git a/src/security.rs b/src/security.rs index a270ee9..abe114e 100644 --- a/src/security.rs +++ b/src/security.rs @@ -2,7 +2,9 @@ use time::OffsetDateTime; -pub use crate::signed::Key; +pub use signed::Key; + +mod signed; /// Join a string and an expiry date together into a string. pub fn encode_expiring_claim(claim: &str, expiry_date: OffsetDateTime) -> String { diff --git a/src/signed.rs b/src/security/signed.rs index 4da6760..4da6760 100644 --- a/src/signed.rs +++ b/src/security/signed.rs |