pub struct Authorizer { /* private fields */ }Expand description
Capability-based authorizer.
Maintains:
- Direct grants: subject → CapabilitySet
- Roles: role name → CapabilitySet
- Role bindings: agent → list of role names
Evaluation order: direct grants → role inheritance → default policy.
Implementations§
Source§impl Authorizer
impl Authorizer
Sourcepub fn new_permissive(audit: Arc<AuditLog>) -> Self
pub fn new_permissive(audit: Arc<AuditLog>) -> Self
Create a permissive authorizer (allow all by default).
Sourcepub fn grant(&self, subject: CapabilitySubject, caps: CapabilitySet)
pub fn grant(&self, subject: CapabilitySubject, caps: CapabilitySet)
Grant a full capability set to a subject.
Sourcepub fn grant_one(&self, subject: CapabilitySubject, cap: Capability)
pub fn grant_one(&self, subject: CapabilitySubject, cap: Capability)
Grant a single capability to a subject.
Sourcepub fn revoke(&self, subject: &CapabilitySubject)
pub fn revoke(&self, subject: &CapabilitySubject)
Revoke all capabilities from a subject.
Sourcepub fn define_role(&self, role_name: &str, caps: CapabilitySet)
pub fn define_role(&self, role_name: &str, caps: CapabilitySet)
Define a named role with a capability set.
Sourcepub fn unbind_role(&self, agent_id: &str, role_name: &str)
pub fn unbind_role(&self, agent_id: &str, role_name: &str)
Remove a role binding from an agent.
Sourcepub fn check(&self, subject: &CapabilitySubject, required: &Capability) -> bool
pub fn check(&self, subject: &CapabilitySubject, required: &Capability) -> bool
Check if a subject has a required capability.
Sourcepub fn require(
&self,
subject: &CapabilitySubject,
required: &Capability,
) -> Result<(), SdkError>
pub fn require( &self, subject: &CapabilitySubject, required: &Capability, ) -> Result<(), SdkError>
Require a capability, returning an error if not granted.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Authorizer
impl !UnwindSafe for Authorizer
impl Freeze for Authorizer
impl Send for Authorizer
impl Sync for Authorizer
impl Unpin for Authorizer
impl UnsafeUnpin for Authorizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more