pub struct AuthConfig { /* private fields */ }Expand description
Resolved API-key configuration: a map of sha256(key) hex → project id, plus
whether the dev bypass is enabled.
Implementations§
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Build from environment with a secure default (dev bypass off):
TRACE_WEFT_API_KEYS: comma-separatedraw_key:project_idpairs.TRACE_WEFT_DEV_MODE=1/true(or0/false): toggle the dev bypass.
With no keys and the bypass off, every request is rejected — use this for production deployments where unauthenticated access must be denied.
Sourcepub fn from_env_local_first() -> Self
pub fn from_env_local_first() -> Self
Build from environment for local-first entry points (CLI/desktop).
Same env vars as [from_env], but when no keys are configured and the
operator hasn’t explicitly set TRACE_WEFT_DEV_MODE, the dev bypass
defaults on so the local UI works without keys. Configuring keys (or
setting TRACE_WEFT_DEV_MODE=0) restores enforcement.
Sourcepub fn new(
raw_keys: impl IntoIterator<Item = (String, String)>,
dev_mode: bool,
) -> Self
pub fn new( raw_keys: impl IntoIterator<Item = (String, String)>, dev_mode: bool, ) -> Self
Construct from raw (key, project_id) pairs, hashing each key. Raw keys
are dropped after hashing.
Sourcepub fn authenticate(&self, headers: &HeaderMap) -> Option<Auth>
pub fn authenticate(&self, headers: &HeaderMap) -> Option<Auth>
Resolve the Authorization: Bearer <key> header to a tenant. Returns
None when no valid key is presented and the dev bypass is off — the
caller should answer 401 in that case.
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§fn clone(&self) -> AuthConfig
fn clone(&self) -> AuthConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for AuthConfig
impl Default for AuthConfig
Source§fn default() -> AuthConfig
fn default() -> AuthConfig
Auto Trait Implementations§
impl Freeze for AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnsafeUnpin for AuthConfig
impl UnwindSafe for AuthConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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