pub struct ProviderBuilder { /* private fields */ }Expand description
Builder for the default (env-driven) authentication provider stack, plus an optional DB-backed API key store and an optional local-group store.
Implementations§
Source§impl ProviderBuilder
impl ProviderBuilder
Sourcepub fn new(prefix: &str) -> ProviderBuilder
pub fn new(prefix: &str) -> ProviderBuilder
Starts a builder scoped to prefix (e.g. "MICROMEGAS_INGESTION", or ""
for the unprefixed default), following the same {prefix}_*-with-fallback
convention as resolve_prefixed_var.
Sourcepub fn with_db_key_store(
self,
pool: Pool<Postgres>,
table: ApiKeyTable,
) -> ProviderBuilder
pub fn with_db_key_store( self, pool: Pool<Postgres>, table: ApiKeyTable, ) -> ProviderBuilder
Attaches a DB-backed key store bound to table, looked up through pool
(expected to be a crate::db_api_key::dedicated_key_store_pool, not a
clone of the caller’s lake pool).
Sourcepub fn with_group_store(self, pool: Pool<Postgres>) -> ProviderBuilder
pub fn with_group_store(self, pool: Pool<Postgres>) -> ProviderBuilder
Attaches a local-group store, looked up through pool (same dedicated-pool
expectation as Self::with_db_key_store). compose() wraps the finished chain in a
MembershipProvider when this is attached.
Sourcepub async fn build(self) -> Result<Option<Arc<dyn AuthProvider>>, Error>
pub async fn build(self) -> Result<Option<Arc<dyn AuthProvider>>, Error>
Builds the composed provider.
Composes, in order: OidcAuthProvider → DbApiKeyAuthProvider; MultiAuthProvider tries
providers in order, so putting the DB provider last means only tokens that are not a valid
JWT ever reach it. The DB provider is always pushed onto the chain whenever a key store is
attached, so a key minted into a previously empty table authenticates on the very next
request, with no restart.
A DB key store with at least one live key counts as “auth configured”;
an empty one does not. When a key store is attached, this runs one cheap
startup existence query (key_store_has_live_rows) and treats a non-empty
result the same as OIDC being present. A failure of that query
(e.g. a missing relation because the schema has not reached migration v5
yet) is propagated as an Err from build() — unless OIDC
already configured auth, in which case the failure is only warn!-logged
and has_live_rows is treated as false, since the query’s result would
be unused either way.
The chain is discarded when nothing counted as configured; use
build_chain() to skip the guard.
Sourcepub async fn build_chain(self) -> Result<Arc<dyn AuthProvider>, Error>
pub async fn build_chain(self) -> Result<Arc<dyn AuthProvider>, Error>
Composes the provider chain with no “is anything configured?” guard.
Composes, in order: OidcAuthProvider → DbApiKeyAuthProvider. The DB provider is always
pushed onto the chain whenever a key store is attached, so a key minted into a previously
empty table authenticates on the very next request, with no restart.
Always returns the chain — never None, because there is no Option —
and never runs key_store_has_live_rows, so unlike build() it cannot
fail on a schema short of migration v5. This is the entry point for a
caller that wants the no-restart property above without inheriting
build()’s startup guard or its existence-query failure mode — e.g. an
embedder folding this chain into a larger MultiAuthProvider via
FlightSqlServer::with_auth_provider.
When nothing at all is configured (no OIDC, no key store)
the returned chain is an empty MultiAuthProvider, which rejects every
request — fail-closed, since the caller asked for no guard. Logs a
warn! in that case, since an empty chain is useless to any caller.
Auto Trait Implementations§
impl !RefUnwindSafe for ProviderBuilder
impl !UnwindSafe for ProviderBuilder
impl Freeze for ProviderBuilder
impl Send for ProviderBuilder
impl Sync for ProviderBuilder
impl Unpin for ProviderBuilder
impl UnsafeUnpin for ProviderBuilder
Blanket Implementations§
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].