Skip to main content

AuthManager

Trait AuthManager 

Source
pub trait AuthManager:
    Debug
    + Send
    + Sync {
    // Required methods
    fn init_session<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        client: &'life1 HttpClient,
        props: &'life2 HashMap<String, String>,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AuthSession>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn catalog_session<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        client: &'life1 HttpClient,
        props: &'life2 HashMap<String, String>,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AuthSession>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn contextual_session<'life0, 'life1, 'async_trait>(
        &'life0 self,
        context: &'life1 SessionContext,
        catalog_session: Arc<dyn AuthSession>,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AuthSession>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Creates the AuthSessions used to authenticate REST catalog requests.

A manager is exclusively scoped to one catalog and must not be reused by other catalogs. It is either created from the rest.auth.type property or injected through RestCatalogBuilder::with_auth_manager or RestSessionCatalogBuilder::with_auth_manager. Catalog initialization calls AuthManager::catalog_session exactly once; the context-specific sessions that AuthManager::contextual_session derives from it may rely on the state established by that call.

Self::init_session and Self::catalog_session are handed the catalog’s HttpClient, which an implementation may clone and store for its own requests (e.g. a token exchange) so that they share the catalog’s connection pool and configuration.

Required Methods§

Source

fn init_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, client: &'life1 HttpClient, props: &'life2 HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AuthSession>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Session used for the initial /v1/config handshake, given the user-supplied properties.

Returns a Box: an init session is used once and released, unlike the shared AuthManager::catalog_session.

Source

fn catalog_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, client: &'life1 HttpClient, props: &'life2 HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AuthSession>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Session used for all subsequent catalog requests, given the properties merged from the user configuration and the server’s config response.

Returns an Arc: this session is shared by concurrent requests for the rest of the catalog’s lifetime. Implementations may carry state (e.g. a cached token) over from the init session.

Provided Methods§

Source

fn contextual_session<'life0, 'life1, 'async_trait>( &'life0 self, context: &'life1 SessionContext, catalog_session: Arc<dyn AuthSession>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn AuthSession>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the authentication session for a specific context.

The catalog calls this method only after Self::catalog_session has succeeded. catalog_session is the catalog session returned by this manager. If the context does not require different authentication, implementations should return catalog_session unchanged.

The catalog does not cache the returned session. Implementations should cache context-specific sessions internally using [SessionContext::session_id] and are responsible for eviction. Reusing a session ID with different context may therefore return the previously cached session.

The catalog calls this method for every request without serializing calls that share a session ID. Caching implementations must guard against concurrently creating multiple sessions for the same context.

No HttpClient is passed. Implementations that need one, e.g. for a token exchange, should store the client handed to Self::catalog_session.

Implementors§