spiffe/bundle/mod.rs
1//! X.509 bundle and JWT bundle types.
2
3use crate::spiffe_id::TrustDomain;
4use std::error::Error;
5
6pub mod jwt;
7pub mod x509;
8
9/// Represents a collection of public keys.
10pub trait Bundle {}
11
12/// Represents a source of bundles queryable by [`TrustDomain`].
13pub trait BundleRefSource {
14 /// The type of the bundles provided by the source.
15 type Item: Bundle;
16
17 /// Returns the reference to bundle (set of public keys authorities) associated to the [`TrustDomain`].
18 /// If it cannot be found a bundle associated to the trust domain, it returns `Ok(None)`.
19 /// If there's is an error in source fetching the bundle, it returns an `Err<Box<dyn Error + Send + Sync + 'static>>`.
20 fn get_bundle_for_trust_domain(
21 &self,
22 trust_domain: &TrustDomain,
23 ) -> Result<Option<&Self::Item>, Box<dyn Error + Send + Sync + 'static>>;
24}
25
26/// Represents a source of bundles queryable by [`TrustDomain`].
27pub trait BundleSource {
28 /// The type of the bundles provided by the source.
29 type Item: Bundle;
30
31 /// Returns a owned bundle (set of public keys authorities) associated to the [`TrustDomain`].
32 /// If it cannot be found a bundle associated to the trust domain, it returns `Ok(None)`.
33 /// If there's is an error in source fetching the bundle, it returns an `Err<Box<dyn Error + Send + Sync + 'static>>`.
34 fn get_bundle_for_trust_domain(
35 &self,
36 trust_domain: &TrustDomain,
37 ) -> Result<Option<Self::Item>, Box<dyn Error + Send + Sync + 'static>>;
38}