Skip to main content

Acl

Struct Acl 

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

A parsed ACL file: which users hold which grants, and until when.

Empty means nobody holds anything, which under a configured ACL denies every request. That is the intended failure mode, and the reason a malformed file is never partially applied.

This type answers no authorization question. It is what the file says; Acl::at turns it into the Effective table that holds at one instant, and that is the only type with allows on it. The split is the whole D66 mechanism: a grant with a deadline is only safe if forgetting the deadline is impossible, and here forgetting it does not compile.

Implementations§

Source§

impl Acl

Source

pub fn parse(text: &str) -> Result<Self, String>

Parses the ACL grammar described in the module documentation.

§Errors

Returns a message naming the offending line number. A file with one bad line does not parse at all: a partially applied ACL would silently revoke somebody’s access.

A deadline already in the past is not an error. It parses, and then never matches: refusing the file would turn one stale line into a node-wide lockout, which is a worse failure than the one it would be reporting. Acl::expired is how the operator sees it.

Source

pub fn grants_node(&self, user: &str) -> bool

Whether user is granted anything at Scope::Node here, at any level and whatever its deadline says.

Deliberately not an Effective question. D36 forbids self-service from issuing node-wide authority at all, and a deadline must never be the thing that enforces that: a grant dated into the past would answer “no” today and “yes” to anyone who reads the same table with a different clock. The rule is about what may be written, so it is asked of what is written.

Source

pub fn at(&self, now: u64) -> Effective

The grants that hold at now, in unix seconds — the only table that answers an authorization question.

Evaluated per request rather than cached across one, so a caller holding this decides every question at a single instant. A grant that lapses mid-request therefore lapses at the next request, not between two checks of the same one.

Source

pub fn expired(&self, now: u64) -> usize

How many grants have a deadline that has already passed at now.

Reported at startup and on reload so a line that is dead on arrival — a typo in the deadline, or a file that outlived what it was granting — is visible without an operator diffing behaviour against intent.

Source

pub fn load(path: &Path) -> Result<Self, String>

Reads and parses the file at path.

§Errors

Returns a message when the file cannot be read, or when it does not parse.

Source

pub fn len(&self) -> usize

Number of grants across all users.

Source

pub fn is_empty(&self) -> bool

Whether the table holds no grants at all, in which case a configured ACL denies everyone.

Source

pub fn merged(&self, other: &Self) -> Self

This table plus other’s grants, as one table.

The union, never an intersection: the operator’s file and the self-service store (D36) each answer for the grants they issued, and neither can withdraw the other’s. Written so that every enforcement point keeps consulting exactly one Acl — the two sources are a detail of where grants come from, not a second decision anybody has to remember to make.

Trait Implementations§

Source§

impl Clone for Acl

Source§

fn clone(&self) -> Acl

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 Acl

Source§

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

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

impl Default for Acl

Source§

fn default() -> Acl

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Acl

§

impl RefUnwindSafe for Acl

§

impl Send for Acl

§

impl Sync for Acl

§

impl Unpin for Acl

§

impl UnsafeUnpin for Acl

§

impl UnwindSafe for Acl

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, 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 = 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.