pub trait AccessControl: Default {
type Id;
// Required methods
fn load<M>(mm: &mut MemoryManager<M>) -> MemoryResult<Self>
where M: MemoryProvider,
Self: Sized;
fn granted(
&self,
id: &Self::Id,
table: TableFingerprint,
perm: TablePerms,
) -> bool;
fn granted_admin(&self, id: &Self::Id) -> bool;
fn granted_manage_acl(&self, id: &Self::Id) -> bool;
fn granted_migrate(&self, id: &Self::Id) -> bool;
fn grant<M>(
&mut self,
id: Self::Id,
grant: PermGrant,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>
where M: MemoryProvider;
fn revoke<M>(
&mut self,
id: &Self::Id,
revoke: PermRevoke,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>
where M: MemoryProvider;
fn remove_identity<M>(
&mut self,
id: &Self::Id,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>
where M: MemoryProvider;
fn perms(&self, id: &Self::Id) -> IdentityPerms;
fn identities(&self) -> Vec<(Self::Id, IdentityPerms)>;
}Expand description
Trait for granular access-control providers.
Implementations gate every CRUD-relevant operation through granted*
predicates. Mutations persist via mm.
The Id associated type lets runtimes use native identity
representations (Vec<u8> for the generic layer, Principal for the
IC adapter, () for the no-op provider).
Required Associated Types§
Required Methods§
Sourcefn load<M>(mm: &mut MemoryManager<M>) -> MemoryResult<Self>where
M: MemoryProvider,
Self: Sized,
fn load<M>(mm: &mut MemoryManager<M>) -> MemoryResult<Self>where
M: MemoryProvider,
Self: Sized,
Loads ACL state from persisted memory.
Sourcefn granted(
&self,
id: &Self::Id,
table: TableFingerprint,
perm: TablePerms,
) -> bool
fn granted( &self, id: &Self::Id, table: TableFingerprint, perm: TablePerms, ) -> bool
Returns whether id is granted perm on table.
Sourcefn granted_admin(&self, id: &Self::Id) -> bool
fn granted_admin(&self, id: &Self::Id) -> bool
Returns whether id carries the admin bypass flag.
Sourcefn granted_manage_acl(&self, id: &Self::Id) -> bool
fn granted_manage_acl(&self, id: &Self::Id) -> bool
Returns whether id carries the manage_acl flag.
Sourcefn granted_migrate(&self, id: &Self::Id) -> bool
fn granted_migrate(&self, id: &Self::Id) -> bool
Returns whether id carries the migrate flag.
Sourcefn grant<M>(
&mut self,
id: Self::Id,
grant: PermGrant,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>where
M: MemoryProvider,
fn grant<M>(
&mut self,
id: Self::Id,
grant: PermGrant,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>where
M: MemoryProvider,
Applies a grant to id, creating the entry if missing.
Sourcefn revoke<M>(
&mut self,
id: &Self::Id,
revoke: PermRevoke,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>where
M: MemoryProvider,
fn revoke<M>(
&mut self,
id: &Self::Id,
revoke: PermRevoke,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>where
M: MemoryProvider,
Applies a revoke to id. No-op if id is not present.
Sourcefn remove_identity<M>(
&mut self,
id: &Self::Id,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>where
M: MemoryProvider,
fn remove_identity<M>(
&mut self,
id: &Self::Id,
mm: &mut MemoryManager<M>,
) -> MemoryResult<()>where
M: MemoryProvider,
Removes id entirely from the ACL.
Sourcefn perms(&self, id: &Self::Id) -> IdentityPerms
fn perms(&self, id: &Self::Id) -> IdentityPerms
Returns the IdentityPerms currently held by id, or the
default (no perms) if id is unknown.
Sourcefn identities(&self) -> Vec<(Self::Id, IdentityPerms)>
fn identities(&self) -> Vec<(Self::Id, IdentityPerms)>
Returns every identity in the ACL together with its perms.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.