Skip to main content

AuthFile

Struct AuthFile 

Source
pub struct AuthFile {
    pub schema_version: u32,
    pub admin: Option<AdminSection>,
    pub read_uplift: Option<ReadUpliftSection>,
}
Expand description

Full auth.toml shape.

Fields§

§schema_version: u32

Schema version sentinel. Always 1 in v1.

§admin: Option<AdminSection>

Admin section — set by mnm login. Hidden from MCP server.

§read_uplift: Option<ReadUpliftSection>

Read-uplift section — set by mnm auth github. Used by MCP + CLI reads.

Implementations§

Source§

impl AuthFile

Source

pub fn read_optional(path: &Path) -> Result<Option<Self>, AuthFileError>

Read and validate an auth.toml from path.

Returns:

  • Ok(Some(AuthFile)) on a present, well-formed file with matching schema.
  • Ok(None) when the file is absent (anonymous mode — EC-39, FR-070).
  • Err(...) on a present but malformed or schema-mismatched file.
§Errors

Returns AuthFileError::Io for I/O failures other than “not found”, AuthFileError::Parse for malformed TOML, and AuthFileError::SchemaVersionMismatch if schema_version is not SCHEMA_VERSION.

Source

pub fn active_admin_token(&self, now: OffsetDateTime) -> Option<&str>

Returns the admin JWT only if present and not expired (now < expires_at).

Source

pub fn active_read_uplift_token(&self, now: OffsetDateTime) -> Option<&str>

Returns the read-uplift bearer only if present and not expired.

Source

pub fn to_toml(&self) -> Result<String, AuthFileError>

Serialize this auth file to a TOML body suitable for writing to disk. Section order is schema_version, [admin], [read_uplift] — matching what mnm login / mnm auth github would have produced.

§Errors

Returns AuthFileError::Serialize on the (effectively never) serialiser failure.

Source

pub fn write(&self, path: &Path) -> Result<(), AuthFileError>

Atomically write the auth file to path, creating the file with mode 0o600 (Unix) and refusing to write if an existing file has looser permissions.

Atomicity comes from a path.tmp sibling that is rename(2)’d into place; concurrent readers will see either the previous file or the new file but never a partial mid-write.

§Errors

Returns AuthFileError::Io on filesystem failure, AuthFileError::Serialize on the (rare) TOML encode failure, or AuthFileError::InsecurePermissions if an existing file at path already has group- or world-readable bits set (we refuse to silently re-narrow them).

Source

pub fn write_admin_token( path: &Path, user_id: impl Into<String>, token: impl Into<String>, expires_at: OffsetDateTime, ) -> Result<(), AuthFileError>

Read the existing file (or build a fresh empty one), update the [admin] section with the supplied JWT + expiry, and persist back to disk under the same permission discipline as AuthFile::write.

§Errors

Returns any variant of AuthFileError that AuthFile::read_optional or AuthFile::write can produce.

Source

pub fn write_read_uplift_token( path: &Path, github_login: impl Into<String>, token: impl Into<String>, expires_at: OffsetDateTime, ) -> Result<(), AuthFileError>

Like AuthFile::write_admin_token but for the [read_uplift] section, used by mnm auth github.

§Errors

See AuthFile::write_admin_token.

Source

pub const fn empty() -> Self

Fresh schema-versioned auth file with no sections populated.

Trait Implementations§

Source§

impl Clone for AuthFile

Source§

fn clone(&self) -> AuthFile

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 AuthFile

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AuthFile

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for AuthFile

Source§

impl PartialEq for AuthFile

Source§

fn eq(&self, other: &AuthFile) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AuthFile

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AuthFile

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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 = 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.
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