Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced default double allocation to one #232

Merged
merged 1 commit into from Jan 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/validation.rs
Expand Up @@ -82,7 +82,23 @@ pub struct Validation {
impl Validation {
/// Create a default validation setup allowing the given alg
pub fn new(alg: Algorithm) -> Validation {
Validation { algorithms: vec![alg], ..Default::default() }
let mut required_claims = HashSet::with_capacity(1);
required_claims.insert("exp".to_owned());

Validation {
required_spec_claims: required_claims,
algorithms: vec![alg],
leeway: 60,

validate_exp: true,
validate_nbf: false,

iss: None,
sub: None,
aud: None,

validate_signature: true,
}
}

/// `aud` is a collection of one or more acceptable audience members
Expand Down Expand Up @@ -116,23 +132,7 @@ impl Validation {

impl Default for Validation {
fn default() -> Self {
let mut required_claims = HashSet::with_capacity(1);
required_claims.insert("exp".to_owned());

Validation {
required_spec_claims: required_claims,
algorithms: vec![Algorithm::HS256],
leeway: 60,

validate_exp: true,
validate_nbf: false,

iss: None,
sub: None,
aud: None,

validate_signature: true,
}
Self::new(Algorithm::HS256)
}
}

Expand Down