pub enum Auth {
Disabled,
Enabled(HashMap<String, Principal>),
}Expand description
The daemon’s token registry. Disabled means no auth was configured — every
request is served as an implicit admin (local/library behavior).
Variants§
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn authenticate(&self, token: Option<&str>) -> Option<Principal>
pub fn authenticate(&self, token: Option<&str>) -> Option<Principal>
Resolve a bearer token to its principal. Disabled always yields an
implicit admin; Enabled yields the matching principal, or None when
the token is missing or unknown (the caller maps that to 401).
Sourcepub fn parse_toml(s: &str) -> Result<Auth, String>
pub fn parse_toml(s: &str) -> Result<Auth, String>
Parse a TOML principals file into an Enabled registry. Duplicate tokens
are an error (ambiguous identity).
Sourcepub fn from_env(
get: impl Fn(&str) -> Option<String>,
read_file: impl Fn(&str) -> Result<String, String>,
) -> Result<Auth, String>
pub fn from_env( get: impl Fn(&str) -> Option<String>, read_file: impl Fn(&str) -> Result<String, String>, ) -> Result<Auth, String>
Resolve the daemon’s auth from the environment (pure — read_file injects
the file IO so this is unit-testable):
GONZALO_AUTH_FILE→ parse that TOML principals file;- else
GONZALO_TOKEN→ a single admin principal (back-compat); - else →
Disabled(open).
Auto Trait Implementations§
impl Freeze for Auth
impl RefUnwindSafe for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl UnsafeUnpin for Auth
impl UnwindSafe for Auth
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request