diff --git a/Cargo.toml b/Cargo.toml index 1133c6e..2af0e53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jsonwebtoken" -version = "8.0.0-beta.3" +version = "8.0.0-beta.4" authors = ["Vincent Prouillet "] license = "MIT" readme = "README.md" @@ -17,7 +17,7 @@ serde = {version = "1.0", features = ["derive"] } ring = { version = "0.16.5", features = ["std"] } base64 = "0.13" # For PEM decoding -pem = "0.8" +pem = "1" simple_asn1 = "0.5" [dev-dependencies] diff --git a/src/validation.rs b/src/validation.rs index 9714250..14a0726 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -70,19 +70,7 @@ pub struct Validation { impl Validation { /// Create a default validation setup allowing the given alg pub fn new(alg: Algorithm) -> Validation { - Validation { - algorithms: vec![alg], - leeway: 0, - - validate_exp: true, - validate_nbf: false, - - iss: None, - sub: None, - aud: None, - - validate_signature: true, - } + Validation { algorithms: vec![alg], ..Default::default() } } /// `aud` is a collection of one or more acceptable audience members @@ -103,6 +91,24 @@ impl Validation { } } +impl Default for Validation { + fn default() -> Self { + Validation { + algorithms: vec![Algorithm::HS256], + leeway: 0, + + validate_exp: true, + validate_nbf: false, + + iss: None, + sub: None, + aud: None, + + validate_signature: true, + } + } +} + /// Gets the current timestamp in the format JWT expect pub fn get_current_timestamp() -> u64 { let start = SystemTime::now();