Skip to main content

BetterAuthCompat

Struct BetterAuthCompat 

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

Runs fastauth on a database a Better Auth app also uses, and lets the two share sign-ins: FastAuth::builder().better_auth_compat(BetterAuthCompat::new(secret).cookie_prefix("vt")).

Applied at .build(), where it overrides the matching settings:

fastauth’s verification rows don’t fit Better Auth’s verification table, so give them their own on the adapter: Sqlx::new(pool).rename("verification", "fastauth_verification").

The cookie cache can’t be used with it: .build() refuses SessionConfig::cookie_cache. fastauth’s own .secret(..) is still needed; it keys everything that isn’t a cookie (encrypted columns, plugin keys, rate-limit buckets).

Implementations§

Source§

impl BetterAuthCompat

Source

pub fn new(secret: impl Into<Vec<u8>>) -> Self

The Better Auth app’s secret (BETTER_AUTH_SECRET), as the app has it: its UTF-8 bytes key the cookie HMAC, with no decoding and no key derivation.

Source

pub fn from_env(var: &str) -> Result<Self, BuildError>

BetterAuthCompat::new with the value of an environment variable, read as it is. Unlike Secret::from_env, a value that happens to be valid base64 isn’t decoded.

Source

pub fn cookie_prefix(self, prefix: impl Into<String>) -> Self

The Better Auth app’s advanced.cookiePrefix (default "better-auth").

Source

pub fn expires_in(self, d: Duration) -> Self

The Better Auth app’s session.expiresIn (14 days unless set; Better Auth’s own default is 7). Both apps should use the same value, since each extends a session to its own.

Source

pub fn update_age(self, d: Duration) -> Self

The Better Auth app’s session.updateAge (one day, Better Auth’s default).

Source

pub fn max_concurrent_hashes(self, n: usize) -> Self

How many scrypt hashes run at once at most (default 8, and never more than the number of CPUs): 32 MiB each, so 256 MiB at most by default.

Trait Implementations§

Source§

impl Clone for BetterAuthCompat

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BetterAuthCompat

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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