Skip to main content

Crate coqui_access_acl

Crate coqui_access_acl 

Source
Expand description

§coqui-access-acl

Version Rust version License: MPL-2.0 Docs CI

Access control lists on items: each item carries a list of entries naming who may do what to it, and this crate decides a request against that list. One model writes each product’s lists as they are: Windows and NFSv4 (ordered allow and deny, inheritance flags), POSIX.1e (classes and a mask), NetBox and TrueNAS RBAC (additive), Proxmox (a walk where the most specific level wins). The consumer stores items and their lists; the crate evaluates. See the narrative docs.

§Features

  • Named rights per item type - a RightsSchema turns names into bits of a growable Rights set; aliases stand for several (generic rights, NFSv4 basic permissions, Proxmox roles), and a cancelling name refuses everything.
  • Five evaluation modes - Ordered, DenyOverrides (the default, since no order can be wrong), Additive, Posix, MostSpecific. A Decision says what was granted, what was denied and which entry decided.
  • Inheritance, both ways - copied at creation (Acl::inherited_by, Windows’ flag table) or walked at check time (AclStore, Proxmox paths).
  • An Authorizer - AclAuthorizer answers coqui-access’s authorizer kind over any AclStore; a store that cannot answer is an error, never a denial.
  • Conditions and tokens - entry conditions are the consumer’s callback (unknown: an allow is skipped, a deny applies); Decision::intersect narrows a person’s decision to a token’s, Decision::union_where_unset adds a second parent’s (a Proxmox pool).
  • Options, not floors - every bound is a default the caller lifts, and what sets a decision off the default (OnMissing::AllowAll, an Everyone allow) is reported as data.

§Installation

cargo add coqui-access-acl --git https://github.com/Boriken-Dev/coqui-access

No Cargo features. It depends on coqui-access alone.

§Quick start

use coqui_access::Person;
use coqui_access_acl::{Acl, Context, Entry, Mode, RightsSchema};

let schema = RightsSchema::builder()
    .rights(["read", "write"])
    .alias("full", ["read", "write"])
    .build()?;
let acl = Acl::new(Mode::DenyOverrides)
    .entry(Entry::allow("group:staff".parse::<coqui_access::Subject>()?, ["full"]))
    .entry(Entry::deny("account:guest".parse::<coqui_access::Subject>()?, ["write"]));

let guest = Person {
    name: "guest".into(),
    groups: vec!["staff".into()],
    ..Person::default()
};
let decision = acl.check(&Context::new(&schema).person(&guest), &schema.rights(["write"])?)?;
assert!(!decision.allowed);
assert_eq!(decision.deciding, Some(1));

§API overview

ItemPurpose
Rights, RightsSchemaRights as bits, and the names and aliases of one item type.
Principal, Entry, Effect, InheritOne line of a list: who, allow or deny, which rights, how it is inherited.
Acl, Mode, ItemAclA list, how its entries combine, and an item’s list with its owner.
Context, DecisionWho asks and with what options; what the check came to.
AclAuthorizercoqui-access’s Authorizer kind over an AclStore.
Child, AclStoreCopied inheritance for a new child; walked inheritance over the consumer’s tree.
Options, Limits, OnMissing, NonDefaultBounds and choices, and what sets them off the default.
Conditions, TruthThe consumer’s decision on an entry’s condition.
AclErrorWhy a schema, list or walk could not be used.

§Development

cargo test -p coqui-access-acl
cargo clippy -p coqui-access-acl --all-targets -- -D warnings

§Releasing

This project follows Semantic Versioning and keeps a CHANGELOG.md. Pushing a tag matching v* triggers the release workflow of the repository.

§License

MPL-2.0 — see LICENSE.

Structs§

Acl
An access control list.
AclAuthorizer
Answers [Authorizer] from the ACLs in a store: the request’s resource is the item, its action a right or alias of schema, its person the requester (signed in, so Authenticated and Everyone entries match).
Context
Everything a check needs besides the ACL and the rights wanted: the schema, who asks, the item’s owner, the consumer’s conditions and the options.
Decision
What a check came to.
Entry
One line of an ACL: who, allow or deny, which rights, and how it is inherited.
Inherit
How an entry passes to what an item contains, in Windows’ terms (NFSv4 uses the same four flags): items is OBJECT_INHERIT, containers CONTAINER_INHERIT, no_propagate NO_PROPAGATE_INHERIT and inherit_only INHERIT_ONLY. In MostSpecific mode, containers is Proxmox’s propagate.
ItemAcl
The ACL of one item, with the owner and owning group its Owner and OwnerGroup entries resolve against. As configuration the subjects are their text.
Limits
Bounds on work and memory. Each is Some(n) by default and None lifts it; none is a security property.
Options
The choices one evaluation runs with.
PrincipalError
Text that names no principal.
Rights
A set of rights, one bit per right a RightsSchema defines. It grows as wide as the schema needs: Windows uses 32 bits, NFSv4 14, Proxmox about 60.
RightsSchema
The rights one type of item has, by name, and the aliases that stand for several.
RightsSchemaBuilder
Builds a RightsSchema.

Enums§

AclError
Why a schema, an ACL or a walk could not be used. Messages give positions, never the names or values involved.
Child
What is made inside a container: a leaf, or a container of its own.
Effect
Whether an entry grants or refuses its rights.
Mode
How an ACL’s entries combine into a decision.
NonDefault
A choice that grants more than the default does, reported as data.
OnMissing
What an item with no ACL at all gets.
Principal
Who an entry applies to, written as text in an entry: a [Subject] (account:<name>, person:<id>, group:<name>), or everyone, authenticated, owner, owner_group, mask.
Truth
What a condition comes to for one request.

Traits§

AclStore
Where items’ ACLs and their places in a tree are kept: the consumer’s storage.
Conditions
Decides an entry’s condition, in whatever language the consumer writes them in: a NetBox-style constraint checked against its database, a Windows conditional expression, a time window.