Skip to main content

Builder

Struct Builder 

Source
pub struct Builder<D, U, P, S, B> { /* private fields */ }
Expand description

Collects configuration. .build() only exists once secret, base_url and database are set: the last three type parameters track that.

Implementations§

Source§

impl<D, U, P, S, B> Builder<D, U, P, S, B>

Source

pub fn secret(self, secret: Secret) -> Builder<D, U, P, Present, B>

The master secret (at least 32 bytes). See Secret::from_env.

Source

pub fn secrets( self, secrets: impl IntoIterator<Item = Secret>, ) -> Builder<D, U, P, Present, B>

Several secrets for rotation: the first signs, all verify.

Source

pub fn base_url(self, url: impl Into<String>) -> Builder<D, U, P, S, Present>

The public URL of the app, e.g. https://acme.dk.

Source

pub fn app_name(self, name: impl Into<String>) -> Self

Source

pub fn base_path(self, path: impl Into<String>) -> Self

Where auth routes live (default /api/auth).

Source

pub fn trusted_origins( self, origins: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Origins allowed to make cookie-carrying requests and to be redirect targets.

Source

pub fn email_password(self, config: EmailPassword) -> Self

Source

pub fn email_verification(self, config: EmailVerification) -> Self

Source

pub fn session(self, config: SessionConfig) -> Self

Source

pub fn cookies(self, config: CookieConfig) -> Self

Source

pub fn rate_limit(self, config: RateLimit) -> Self

Source

pub fn client_ip(self, source: ClientIp) -> Self

Source

pub fn mailer(self, mailer: impl Mailer) -> Self

Source

pub fn user_fields<U2: Fields>(self) -> Builder<D, U2, P, S, B>

The app’s own columns on user.

Source

pub fn plugin<Pl: Plugin, I>(self, plugin: Pl) -> Builder<D, U, P::Out, S, B>
where P: Append<Pl>, Pl::Requires: Satisfied<P, I>,

Registers a plugin. Its Requires must already be registered.

Source§

impl<U, P, S, B> Builder<NoDatabase, U, P, S, B>

Source

pub fn database<D: Adapter>(self, db: D) -> Builder<D, U, P, S, B>

Source§

impl<D: Adapter, U, P, S, B> Builder<D, U, P, S, B>

Source

pub fn configure( self, init: impl FnOnce(&mut PluginBuilder<'_, D>) + Send + 'static, ) -> Self

Registers app-level hooks, gates, resolvers or endpoints, like a plugin’s init.

Source

pub fn on<Ev, F, Fut>(self, handler: F) -> Self
where Ev: Event, F: Fn(Ev, Ctx<D>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<(), AuthError>> + Send + 'static,

Runs handler after every endpoint that emits Ev.

Source§

impl<D: Adapter, U: Fields, P: PluginSet> Builder<D, U, P, Present, Present>

Source

pub fn build(self) -> Result<Auth<D, U, P>, BuildError>

Trait Implementations§

Source§

impl<D, U, P, S, B> Debug for Builder<D, U, P, S, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D, U, P, S, B> !RefUnwindSafe for Builder<D, U, P, S, B>

§

impl<D, U, P, S, B> !Sync for Builder<D, U, P, S, B>

§

impl<D, U, P, S, B> !UnwindSafe for Builder<D, U, P, S, B>

§

impl<D, U, P, S, B> Forget for Builder<D, U, P, S, B>

§

impl<D, U, P, S, B> Freeze for Builder<D, U, P, S, B>
where D: Freeze, P: Freeze, Vec<Box<dyn FnOnce(&mut PluginBuilder<'_, D>) + Send>>: Freeze, PhantomData<fn() -> (U, S, B)>: Freeze,

§

impl<D, U, P, S, B> Move for Builder<D, U, P, S, B>

§

impl<D, U, P, S, B> Send for Builder<D, U, P, S, B>
where P: Send, D: Send, Vec<Box<dyn FnOnce(&mut PluginBuilder<'_, D>) + Send>>: Send, PhantomData<fn() -> (U, S, B)>: Send,

§

impl<D, U, P, S, B> Unpin for Builder<D, U, P, S, B>
where P: Unpin, D: Unpin, Vec<Box<dyn FnOnce(&mut PluginBuilder<'_, D>) + Send>>: Unpin, PhantomData<fn() -> (U, S, B)>: Unpin,

§

impl<D, U, P, S, B> UnsafeUnpin for Builder<D, U, P, S, B>

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.

Source§

impl<T> Instrument for T

Source§

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

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

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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