pub struct FederationKeyResolver { /* private fields */ }Expand description
Resolves external issuer URLs to Ed25519 verifying keys via JWKS.
Thread-safe (uses Arc<RwLock<...>>). Caches keys to avoid fetching
on every request. Falls back to OIDC metadata discovery if no explicit
JWKS URI is configured.
By default all JWKS URIs must use HTTPS with TLS certificate verification.
Set allow_http: true in TrustedIssuerConfig on a per-issuer basis to
permit plain HTTP (development / internal use only).
Implementations§
Source§impl FederationKeyResolver
impl FederationKeyResolver
pub fn new(trusted_issuers: &HashMap<String, TrustedIssuerConfig>) -> Self
Sourcepub fn with_policy_client(self, client: Arc<PolicyClient>) -> Self
pub fn with_policy_client(self, client: Arc<PolicyClient>) -> Self
Wire the PolicyService client so [get_keys] enforces the
federation:register trust gate before any HTTPS fetch. When
set, calls to get_keys for issuers that aren’t currently
permitted by PolicyService policy return Err — fail-closed,
matching the CIMD client path.
Sourcepub fn with_discovery_client(self, client: Arc<DiscoveryClient>) -> Self
pub fn with_discovery_client(self, client: Arc<DiscoveryClient>) -> Self
Phase 0.5 Stage D — wire a DiscoveryService client for federation
directory consultation. When set, [get_keys] will try fetching the
issuer’s signed entity statement via DiscoveryService before falling
back to HTTPS JWKS fetch.
Conservative on errors: any failure of the DiscoveryService path (network, parse, missing entity, no Ed25519 key) falls through to the existing HTTPS path. The resolver never downgrades trust based on missing data — if both Discovery AND HTTPS fail, key resolution fails and the caller rejects the JWT.
Sourcepub fn is_trusted(&self, issuer: &str) -> bool
pub fn is_trusted(&self, issuer: &str) -> bool
Returns true if this issuer is in the trusted list.
Sourcepub async fn get_keys(
&self,
issuer: &str,
kid: Option<&str>,
) -> Result<Vec<FederationKey>>
pub async fn get_keys( &self, issuer: &str, kid: Option<&str>, ) -> Result<Vec<FederationKey>>
Get the Ed25519 candidate verifying keys for an issuer, fetching / refreshing JWKS as needed. See the trait docs for the rotation-aware key-set contract (#1185).
Uses a single Mutex for both cache reads and writes so that concurrent
requests for the same issuer serialise: the second waiter re-checks the
cache after the first finishes, finding a fresh entry rather than issuing
a redundant JWKS fetch.
Trait Implementations§
Source§impl FederationKeySource for FederationKeyResolver
impl FederationKeySource for FederationKeyResolver
Source§fn is_trusted(&self, issuer: &str) -> bool
fn is_trusted(&self, issuer: &str) -> bool
Source§fn get_keys<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 str,
kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<FederationKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_keys<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 str,
kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<FederationKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
issuer. Read moreAuto Trait Implementations§
impl !Freeze for FederationKeyResolver
impl !RefUnwindSafe for FederationKeyResolver
impl Send for FederationKeyResolver
impl Sync for FederationKeyResolver
impl Unpin for FederationKeyResolver
impl UnsafeUnpin for FederationKeyResolver
impl !UnwindSafe for FederationKeyResolver
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request