huskarl_core/crypto/verifier/
error.rs1use snafu::Snafu;
2
3use crate::BoxedError;
4
5#[derive(Debug, Snafu)]
7#[snafu(visibility(pub(crate)))]
8pub enum VerifyError<E: crate::Error> {
9 #[snafu(display("no matching key"))]
11 NoMatchingKey,
12 #[snafu(display("ambiguous key: multiple keys match but token has no kid"))]
14 AmbiguousKeyMatch,
15 #[snafu(display("signature mismatch"))]
17 SignatureMismatch,
18 #[snafu(transparent)]
20 Other {
21 source: E,
23 },
24}
25
26impl<E: crate::Error> crate::Error for VerifyError<E> {
27 fn is_retryable(&self) -> bool {
28 match self {
29 VerifyError::NoMatchingKey
30 | VerifyError::AmbiguousKeyMatch
31 | VerifyError::SignatureMismatch => false,
32 VerifyError::Other { source } => source.is_retryable(),
33 }
34 }
35}
36
37#[derive(Debug, Snafu)]
39pub enum CreateVerifierError {
40 #[snafu(display("Unsupported key"))]
42 UnsupportedKey,
43 #[snafu(display("A JWKS URI is required to build a JWS verifier"))]
45 MissingJwksUri,
46 #[snafu(transparent)]
48 Other {
49 source: BoxedError,
51 },
52}
53
54impl crate::Error for CreateVerifierError {
55 fn is_retryable(&self) -> bool {
56 match self {
57 CreateVerifierError::UnsupportedKey | CreateVerifierError::MissingJwksUri => false,
58 CreateVerifierError::Other { source } => source.is_retryable(),
59 }
60 }
61}