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
impl AccessScope
Sourcepub fn from_constraints(constraints: Vec<ScopeConstraint>) -> Self
pub fn from_constraints(constraints: Vec<ScopeConstraint>) -> Self
Create an access scope from a list of constraints (OR-ed).
Sourcepub fn single(constraint: ScopeConstraint) -> Self
pub fn single(constraint: ScopeConstraint) -> Self
Create an access scope with a single constraint.
Sourcepub fn allow_all() -> Self
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.
Sourcepub fn for_tenants(ids: Vec<Uuid>) -> Self
pub fn for_tenants(ids: Vec<Uuid>) -> Self
Create a scope for a set of tenant IDs.
Sourcepub fn for_tenant(id: Uuid) -> Self
pub fn for_tenant(id: Uuid) -> Self
Create a scope for a single tenant ID.
Sourcepub fn for_resources(ids: Vec<Uuid>) -> Self
pub fn for_resources(ids: Vec<Uuid>) -> Self
Create a scope for a set of resource IDs.
Sourcepub fn for_resource(id: Uuid) -> Self
pub fn for_resource(id: Uuid) -> Self
Create a scope for a single resource ID.
Sourcepub fn constraints(&self) -> &[ScopeConstraint]
pub fn constraints(&self) -> &[ScopeConstraint]
The constraints in this scope (OR-ed).
Sourcepub fn is_unconstrained(&self) -> bool
pub fn is_unconstrained(&self) -> bool
Returns true if this scope is unconstrained (allow-all).
Sourcepub fn is_deny_all(&self) -> bool
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.
Sourcepub fn all_values_for(&self, property: &str) -> Vec<&ScopeValue>
pub fn all_values_for(&self, property: &str) -> Vec<&ScopeValue>
Collect all values for a given property across all constraints.
Sourcepub fn all_uuid_values_for(&self, property: &str) -> Vec<Uuid>
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.
Sourcepub fn contains_value(&self, property: &str, value: &ScopeValue) -> bool
pub fn contains_value(&self, property: &str, value: &ScopeValue) -> bool
Check if any constraint has a filter matching the given property and value.
Sourcepub fn contains_uuid(&self, property: &str, id: Uuid) -> bool
pub fn contains_uuid(&self, property: &str, id: Uuid) -> bool
Check if any constraint has a filter matching the given property and UUID.
Sourcepub fn has_property(&self, property: &str) -> bool
pub fn has_property(&self, property: &str) -> bool
Check if any constraint references the given property.
Trait Implementations§
Source§impl Clone for AccessScope
impl Clone for AccessScope
Source§fn clone(&self) -> AccessScope
fn clone(&self) -> AccessScope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more