Skip to main content

ExternalAuthProviderRegistry

Struct ExternalAuthProviderRegistry 

Source
pub struct ExternalAuthProviderRegistry { /* private fields */ }
Expand description

Registry of external authentication provider drivers keyed by provider kind.

The registry is the shared capability boundary for application services. Callers can use it to list descriptors for admin surfaces, gate stored provider configs before a login flow starts, and retrieve the runtime driver for a validated provider. The registry deliberately does not know how providers are stored in a product database; applications adapt their own rows into ExternalAuthProviderConfig immediately before using this type.

Implementations§

Source§

impl ExternalAuthProviderRegistry

Source

pub fn empty() -> Self

Creates an empty registry with no built-in provider drivers.

This is useful for applications that want a fully explicit provider list, tests that need deterministic registration behavior across Cargo feature sets, or plugin hosts that build a registry from externally supplied drivers.

Source

pub fn new() -> Self

Creates a registry populated with all feature-enabled built-in drivers.

Source

pub fn with_external_registrations<F>(configure: F) -> Result<Self>
where F: FnOnce(&mut Self) -> Result<()>,

Creates a built-in registry and lets an external system append registrations.

This is the intended integration point for application-level extension systems: the caller receives a mutable registry, calls ExternalAuthProviderRegistry::add for each external driver it wants to expose, and returns any setup error. Built-in drivers are registered before the callback runs, so external systems cannot accidentally replace them through the non-replacing add API.

Source

pub fn add<D>(&mut self, driver: D) -> Result<()>
where D: ExternalAuthProviderDriver + 'static,

Adds a driver if its provider kind is not already registered.

Use this for product-specific or plugin-provided drivers. Duplicate provider kinds return a configuration error instead of replacing the existing driver, which keeps built-in behavior stable when external systems are enabled.

Source

pub fn add_arc( &mut self, driver: Arc<dyn ExternalAuthProviderDriver>, ) -> Result<()>

Adds an already shared driver if its provider kind is not already registered.

Source

pub fn register<D>(&mut self, driver: D) -> Result<()>
where D: ExternalAuthProviderDriver + 'static,

Registers or replaces a driver for its provider kind.

Use this only when replacement is intentional, such as tests or product-level overrides. The driver must still report a descriptor for the same provider kind that it registers.

Source

pub fn register_arc( &mut self, driver: Arc<dyn ExternalAuthProviderDriver>, ) -> Result<()>

Registers or replaces an already shared driver for its provider kind.

Source

pub fn supported_kinds( &self, ) -> impl Iterator<Item = ExternalAuthProviderKind> + '_

Iterates over registered provider kinds.

Source

pub fn contains(&self, kind: ExternalAuthProviderKind) -> bool

Returns whether a driver for kind is registered.

Source

pub fn descriptors(&self) -> Vec<ExternalAuthProviderDescriptor>

Returns registered provider descriptors sorted by provider kind.

Source

pub fn descriptor_for( &self, kind: ExternalAuthProviderKind, ) -> Result<ExternalAuthProviderDescriptor>

Returns the descriptor for a registered provider kind.

Source

pub fn ensure_provider_supported( &self, kind: ExternalAuthProviderKind, ) -> Result<()>

Ensures that a provider kind is enabled in this registry.

This is useful for service-layer guards that need to reject disabled provider kinds without constructing a login flow or exposing the underlying driver.

Source

pub fn validate_provider_config( &self, provider: &ExternalAuthProviderConfig, ) -> Result<ExternalAuthProviderDescriptor>

Validates that a product-owned provider config matches a registered driver descriptor.

This catches configuration drift before provider-specific network calls run. The method checks that the provider kind is enabled and that the stored protocol matches the driver’s declared protocol. It returns the descriptor so callers can keep using the capability data without another registry lookup.

Source

pub fn driver_for_provider( &self, provider: &ExternalAuthProviderConfig, ) -> Result<Arc<dyn ExternalAuthProviderDriver>>

Returns the registered driver for a provider config after validating the config boundary.

Product services should prefer this method when starting authorization, exchanging a callback, or testing a provider because it applies the same registry-level gates for every flow.

Source

pub fn get_driver( &self, kind: ExternalAuthProviderKind, ) -> Result<Arc<dyn ExternalAuthProviderDriver>>

Returns a registered driver by provider kind.

Source

pub fn oidc(&self) -> Result<Arc<dyn ExternalAuthProviderDriver>>

Returns the OIDC driver from this registry.

Trait Implementations§

Source§

impl Default for ExternalAuthProviderRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,