Skip to main content

AccessScope

Struct AccessScope 

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

A disjunction (OR) of scope constraints defining what data is accessible.

Each constraint is an independent access path (OR-ed). Filters within a constraint are AND-ed. An unconstrained scope bypasses row-level filtering.

§Examples

use modkit_security::access_scope::{AccessScope, ScopeConstraint, ScopeFilter, pep_properties};
use uuid::Uuid;

// deny-all (default)
let scope = AccessScope::deny_all();
assert!(scope.is_deny_all());

// single tenant
let tid = Uuid::new_v4();
let scope = AccessScope::for_tenant(tid);
assert!(!scope.is_deny_all());
assert!(scope.contains_uuid(pep_properties::OWNER_TENANT_ID, tid));

Implementations§

Source§

impl AccessScope

Source

pub fn from_constraints(constraints: Vec<ScopeConstraint>) -> Self

Create an access scope from a list of constraints (OR-ed).

Source

pub fn single(constraint: ScopeConstraint) -> Self

Create an access scope with a single constraint.

Source

pub fn allow_all() -> Self

Create an “allow all” (unconstrained) scope.

This represents a legitimate PDP decision with no row-level filtering. Not a bypass — it’s a valid authorization outcome.

Source

pub fn deny_all() -> Self

Create a “deny all” scope (no access).

Source

pub fn for_tenants(ids: Vec<Uuid>) -> Self

Create a scope for a set of tenant IDs.

Source

pub fn for_tenant(id: Uuid) -> Self

Create a scope for a single tenant ID.

Source

pub fn for_resources(ids: Vec<Uuid>) -> Self

Create a scope for a set of resource IDs.

Source

pub fn for_resource(id: Uuid) -> Self

Create a scope for a single resource ID.

Source

pub fn constraints(&self) -> &[ScopeConstraint]

The constraints in this scope (OR-ed).

Source

pub fn is_unconstrained(&self) -> bool

Returns true if this scope is unconstrained (allow-all).

Source

pub fn is_deny_all(&self) -> bool

Returns true if this scope denies all access.

A scope is deny-all when it is not unconstrained and has no constraints.

Source

pub fn all_values_for(&self, property: &str) -> Vec<&ScopeValue>

Collect all values for a given property across all constraints.

Source

pub fn all_uuid_values_for(&self, property: &str) -> Vec<Uuid>

Collect all UUID values for a given property across all constraints.

Convenience wrapper — skips non-UUID values.

Source

pub fn contains_value(&self, property: &str, value: &ScopeValue) -> bool

Check if any constraint has a filter matching the given property and value.

Source

pub fn contains_uuid(&self, property: &str, id: Uuid) -> bool

Check if any constraint has a filter matching the given property and UUID.

Source

pub fn has_property(&self, property: &str) -> bool

Check if any constraint references the given property.

Trait Implementations§

Source§

impl Clone for AccessScope

Source§

fn clone(&self) -> AccessScope

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AccessScope

Source§

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

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

impl Default for AccessScope

Source§

fn default() -> Self

Default is deny-all: no constraints and not unconstrained.

Source§

impl PartialEq for AccessScope

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 StructuralPartialEq for AccessScope

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