1use spiffe::SpiffeId;
2
3pub type Result<T> = std::result::Result<T, Error>;
5
6#[expect(clippy::error_impl_error, reason = "unfortunate public API")]
8#[derive(Debug, thiserror::Error)]
9#[non_exhaustive]
10pub enum Error {
11 #[error("x509 source has no current SVID")]
13 NoSvid,
14
15 #[error("x509 source is closed")]
17 SourceClosed,
18
19 #[error("x509 source has no bundle for trust domain {0}")]
21 NoBundle(spiffe::TrustDomain),
22
23 #[error("trust domain {0} is not allowed by policy")]
25 TrustDomainNotAllowed(spiffe::TrustDomain),
26
27 #[error("authorizer configuration error: {0}")]
29 AuthorizerConfig(#[from] AuthorizerConfigError),
30
31 #[error("failed building rustls certified key: {0}")]
33 CertifiedKey(String),
34
35 #[error("failed parsing peer certificate: {0}")]
37 CertParse(String),
38
39 #[error("peer is missing SPIFFE ID URI SAN")]
41 MissingSpiffeId,
42
43 #[error("peer certificate has multiple SPIFFE ID URI SANs")]
45 MultipleSpiffeIds,
46
47 #[error("peer SPIFFE ID is not authorized: {0}")]
49 UnauthorizedSpiffeId(SpiffeId),
50
51 #[error("rustls verifier builder error: {0}")]
53 VerifierBuilder(String),
54
55 #[error("rustls error: {0}")]
57 Rustls(#[from] rustls::Error),
58
59 #[error("x509 source error: {0}")]
61 Source(#[from] spiffe::x509_source::X509SourceError),
62
63 #[error("internal: {0}")]
65 Internal(String),
66
67 #[error("tokio runtime is required but not available in the current context")]
69 NoTokioRuntime,
70
71 #[error("no root certificates were accepted into root certificate store")]
76 EmptyRootStore,
77
78 #[error("no usable root certificate stores could be built from any trust domain bundle")]
85 NoUsableRootStores,
86}
87
88#[expect(unnameable_types, reason = "exposed as a source error")]
90#[derive(Debug, thiserror::Error)]
91#[non_exhaustive]
92pub enum AuthorizerConfigError {
93 #[error("invalid SPIFFE ID: {0}")]
95 InvalidSpiffeId(String),
96
97 #[error("invalid trust domain: {0}")]
99 InvalidTrustDomain(String),
100}