pub struct AuthorizationService<S = MemoryStorage>{
pub role_system: AsyncRoleSystem<S>,
/* private fields */
}
Expand description
Enhanced authorization service providing enterprise-grade RBAC
Fields§
§role_system: AsyncRoleSystem<S>
The async role system from role-system v1.0
Implementations§
Source§impl AuthorizationService<MemoryStorage>
impl AuthorizationService<MemoryStorage>
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Create a new authorization service with default configuration
Sourcepub async fn with_config(config: AuthorizationConfig) -> Result<Self>
pub async fn with_config(config: AuthorizationConfig) -> Result<Self>
Create a new authorization service with custom configuration
Source§impl<S> AuthorizationService<S>
impl<S> AuthorizationService<S>
Sourcepub async fn with_storage(
storage: S,
config: AuthorizationConfig,
) -> Result<Self>
pub async fn with_storage( storage: S, config: AuthorizationConfig, ) -> Result<Self>
Create authorization service with custom storage
Sourcepub async fn check_permission(
&self,
user_id: &str,
action: &str,
resource_type: &str,
context: Option<&HashMap<String, String>>,
) -> Result<bool>
pub async fn check_permission( &self, user_id: &str, action: &str, resource_type: &str, context: Option<&HashMap<String, String>>, ) -> Result<bool>
Check if a user has permission to perform an action on a resource
Sourcepub async fn check_api_permission(
&self,
user_id: &str,
method: &str,
endpoint: &str,
context: &HashMap<String, String>,
) -> Result<bool>
pub async fn check_api_permission( &self, user_id: &str, method: &str, endpoint: &str, context: &HashMap<String, String>, ) -> Result<bool>
Check API endpoint permission
Sourcepub async fn assign_role(&self, user_id: &str, role_name: &str) -> Result<()>
pub async fn assign_role(&self, user_id: &str, role_name: &str) -> Result<()>
Assign a role to a user
Sourcepub async fn remove_role(&self, user_id: &str, role_name: &str) -> Result<()>
pub async fn remove_role(&self, user_id: &str, role_name: &str) -> Result<()>
Remove a role from a user
Sourcepub async fn elevate_role(
&self,
user_id: &str,
role_name: &str,
duration_seconds: Option<u64>,
) -> Result<()>
pub async fn elevate_role( &self, user_id: &str, role_name: &str, duration_seconds: Option<u64>, ) -> Result<()>
Temporarily elevate a user’s role
Sourcepub async fn get_user_roles(&self, user_id: &str) -> Result<Vec<String>>
pub async fn get_user_roles(&self, user_id: &str) -> Result<Vec<String>>
Get all roles assigned to a user
Sourcepub async fn create_role(
&self,
name: &str,
description: &str,
permissions: Vec<Permission>,
parent_roles: Option<Vec<String>>,
) -> Result<()>
pub async fn create_role( &self, name: &str, description: &str, permissions: Vec<Permission>, parent_roles: Option<Vec<String>>, ) -> Result<()>
Create a new role
Sourcepub async fn get_role_hierarchy(&self, role_id: &str) -> Result<Vec<String>>
pub async fn get_role_hierarchy(&self, role_id: &str) -> Result<Vec<String>>
Get role hierarchy (using new role-system v1.1.1 features)
Sourcepub async fn get_role_metadata(&self, role_id: &str) -> Result<String>
pub async fn get_role_metadata(&self, role_id: &str) -> Result<String>
Test role hierarchy metadata access
Sourcepub async fn delete_role(&self, _name: &str) -> Result<()>
pub async fn delete_role(&self, _name: &str) -> Result<()>
Delete a role
Auto Trait Implementations§
impl<S> Freeze for AuthorizationService<S>
impl<S = MemoryStorage> !RefUnwindSafe for AuthorizationService<S>
impl<S> Send for AuthorizationService<S>
impl<S> Sync for AuthorizationService<S>
impl<S> Unpin for AuthorizationService<S>
impl<S = MemoryStorage> !UnwindSafe for AuthorizationService<S>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more