Skip to main content

ReadPolicy

Trait ReadPolicy 

Source
pub trait ReadPolicy:
    Send
    + Sync
    + Debug {
    // Required method
    fn resolve<'life0, 'life1, 'async_trait>(
        &'life0 self,
        caller: &'life1 AuthContext,
    ) -> Pin<Box<dyn Future<Output = Result<ReadableAudiences, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

Resolves the set of audiences an authenticated caller may read.

resolve can never return “all” – ReadScope::All is deliberately not a policy output. It is the marker only internal (non-request) callers pass, which is what keeps “who granted themselves All?” a greppable question with a small, auditable answer set. A policy that wants to be maximally permissive still has to enumerate the audiences that make it so.

async and fallible because grants can be resolved from a store – nested groups, plus group→audience grants – which cannot live behind a sync, infallible signature. AudienceReadPolicy is fallible today whenever a DbAudienceGrantsSource is attached via with_store – a cold-start store outage with no prior successful load returns Err, which caller_context (flight_sql_service_impl.rs) maps to Status::unavailable. Without a store attached it still cannot fail.

Every caller must deny on Err. An Err here means “the policy could not be evaluated” – never soften it into ReadableAudiences::new(Arc::from([])) (that would read as a legitimate, audited fail-closed decision) and never into ReadScope::All (a silent fail-open bypass).

Required Methods§

Source

fn resolve<'life0, 'life1, 'async_trait>( &'life0 self, caller: &'life1 AuthContext, ) -> Pin<Box<dyn Future<Output = Result<ReadableAudiences, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Resolves caller’s readable-audience set, or Err if the policy could not be evaluated (e.g. a backing store outage once a store-backed policy lands).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§