Skip to content

Commit d6151bd

Browse files
committed
Uncomment the algorithm matching in verify_signature again
This was commented out with the note that it wasn't "captured anywhere," presumably in tests, but is present in similar form in the pre-decoupling version of the code.
1 parent b8d2906 commit d6151bd

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/decoding.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ pub fn decode_header(token: &str) -> Result<Header> {
321321
Header::from_encoded(header)
322322
}
323323

324-
/// Verify signature of a JWT, and return header object and raw payload
324+
/// Verify the signature of a JWT, and return a header object and raw payload.
325325
///
326326
/// If the token or its signature is invalid, it will return an error.
327327
fn verify_signature<'a>(
@@ -333,14 +333,13 @@ fn verify_signature<'a>(
333333
return Err(new_error(ErrorKind::MissingAlgorithm));
334334
}
335335

336-
// Todo: This behaviour is currently not captured anywhere.
337-
// if validation.validate_signature {
338-
// for alg in &validation.algorithms {
339-
// if key.family != alg.family() {
340-
// return Err(new_error(ErrorKind::InvalidAlgorithm));
341-
// }
342-
// }
343-
// }
336+
if validation.validate_signature {
337+
for alg in &validation.algorithms {
338+
if verifying_provider.algorithm().family() != alg.family() {
339+
return Err(new_error(ErrorKind::InvalidAlgorithm));
340+
}
341+
}
342+
}
344343

345344
let (signature, message) = expect_two!(token.rsplitn(2, '.'));
346345
let (payload, header) = expect_two!(message.rsplitn(2, '.'));

0 commit comments

Comments
 (0)