Struct RbacService

Source
pub struct RbacService<S: RbacStorage> { /* private fields */ }
Expand description

Main RBAC service that coordinates permission checking

Implementations§

Source§

impl<S: RbacStorage> RbacService<S>

Source

pub fn new(storage: S) -> Self

Create a new RBAC service with the given storage backend

Source

pub async fn create_permission( &self, permission: &Permission, ) -> Result<(), RbacError>

Create a new permission

Source

pub async fn get_permission( &self, name: &str, ) -> Result<Option<Permission>, RbacError>

Get a permission by name

Source

pub async fn delete_permission(&self, name: &str) -> Result<(), RbacError>

Delete a permission

Source

pub async fn create_role(&self, role: &Role) -> Result<(), RbacError>

Create a new role

Source

pub async fn get_role(&self, name: &str) -> Result<Option<Role>, RbacError>

Get a role by name

Source

pub async fn delete_role(&self, name: &str) -> Result<(), RbacError>

Delete a role

Source

pub async fn assign_permission_to_role( &self, permission_name: &str, role_name: &str, ) -> Result<(), RbacError>

Assign a permission to a role

Source

pub async fn remove_permission_from_role( &self, permission_name: &str, role_name: &str, ) -> Result<(), RbacError>

Remove a permission from a role

Source

pub async fn get_permissions_for_role( &self, role_name: &str, ) -> Result<Vec<Permission>, RbacError>

Get all permissions for a role

Source

pub async fn assign_role_to_subject( &self, role_name: &str, subject_id: &str, ) -> Result<(), RbacError>

Assign a role to a subject

Source

pub async fn remove_role_from_subject( &self, role_name: &str, subject_id: &str, ) -> Result<(), RbacError>

Remove a role from a subject

Source

pub async fn get_roles_for_subject( &self, subject_id: &str, ) -> Result<Vec<Role>, RbacError>

Get all roles for a subject

Source

pub async fn assign_permission_to_subject( &self, permission_name: &str, subject_id: &str, ) -> Result<(), RbacError>

Assign a permission directly to a subject

Source

pub async fn remove_permission_from_subject( &self, permission_name: &str, subject_id: &str, ) -> Result<(), RbacError>

Remove a permission from a subject

Source

pub async fn get_direct_permissions_for_subject( &self, subject_id: &str, ) -> Result<Vec<Permission>, RbacError>

Get all direct permissions for a subject (not including those from roles)

Source

pub async fn subject_has_permission( &self, subject_id: &str, permission_name: &str, ) -> Result<bool, RbacError>

Check if a subject has a specific permission (either directly or via roles)

Auto Trait Implementations§

§

impl<S> Freeze for RbacService<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for RbacService<S>
where S: RefUnwindSafe,

§

impl<S> Send for RbacService<S>

§

impl<S> Sync for RbacService<S>

§

impl<S> Unpin for RbacService<S>
where S: Unpin,

§

impl<S> UnwindSafe for RbacService<S>
where S: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,