Add back Validation::default()

Closes #208
This commit is contained in:
Vincent Prouillet 2021-10-10 20:44:53 +02:00
parent 2e8aa8d3f8
commit 733d29aa87
2 changed files with 21 additions and 15 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "jsonwebtoken"
version = "8.0.0-beta.3"
version = "8.0.0-beta.4"
authors = ["Vincent Prouillet <hello@vincentprouillet.com>"]
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]

View File

@ -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();