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: u32Schema 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
impl AuthFile
Sourcepub fn read_optional(path: &Path) -> Result<Option<Self>, AuthFileError>
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.
Sourcepub fn active_admin_token(&self, now: OffsetDateTime) -> Option<&str>
pub fn active_admin_token(&self, now: OffsetDateTime) -> Option<&str>
Returns the admin JWT only if present and not expired (now < expires_at).
Sourcepub fn active_read_uplift_token(&self, now: OffsetDateTime) -> Option<&str>
pub fn active_read_uplift_token(&self, now: OffsetDateTime) -> Option<&str>
Returns the read-uplift bearer only if present and not expired.
Sourcepub fn to_toml(&self) -> Result<String, AuthFileError>
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.
Sourcepub fn write(&self, path: &Path) -> Result<(), AuthFileError>
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).
Sourcepub fn write_admin_token(
path: &Path,
user_id: impl Into<String>,
token: impl Into<String>,
expires_at: OffsetDateTime,
) -> Result<(), AuthFileError>
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.
Sourcepub fn write_read_uplift_token(
path: &Path,
github_login: impl Into<String>,
token: impl Into<String>,
expires_at: OffsetDateTime,
) -> Result<(), AuthFileError>
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
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AuthFile
impl<'de> Deserialize<'de> for AuthFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for AuthFile
impl StructuralPartialEq for AuthFile
Auto Trait Implementations§
impl Freeze for AuthFile
impl RefUnwindSafe for AuthFile
impl Send for AuthFile
impl Sync for AuthFile
impl Unpin for AuthFile
impl UnsafeUnpin for AuthFile
impl UnwindSafe for AuthFile
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.