Skip to content

Commit

Permalink
fix: raw JWKS --secret for ES256/ES384 alg
Browse files Browse the repository at this point in the history
  • Loading branch information
vdbulcke committed Jan 12, 2024
1 parent 24eb883 commit 81a31ae
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/translators/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ pub fn decoding_key_from_secret(
}
Algorithm::ES256 | Algorithm::ES384 => {
if !&secret_string.starts_with('@') {
return Err(JWTError::Internal(format!(
"Secret for {alg:?} must be a file path starting with @",
)));
// allows to read JWKS from argument (e.g. output of 'curl https://auth.domain.com/jwks.json')
let secret = secret_string.as_bytes().to_vec();
return decoding_key_from_jwks_secret(&secret, header);
}

let secret = slurp_file(&secret_string.chars().skip(1).collect::<String>());
Expand All @@ -95,9 +95,9 @@ pub fn decoding_key_from_secret(
}
Algorithm::EdDSA => {
if !&secret_string.starts_with('@') {
// allows to read JWKS from argument (e.g. output of 'curl https://auth.domain.com/jwks.json')
let secret = secret_string.as_bytes().to_vec();
return decoding_key_from_jwks_secret(&secret, header);
return Err(JWTError::Internal(format!(
"Secret for {alg:?} must be a file path starting with @",
)));
}

let secret = slurp_file(&secret_string.chars().skip(1).collect::<String>());
Expand Down

0 comments on commit 81a31ae

Please sign in to comment.