Skip to main content

AuthorizationServiceTrait

Trait AuthorizationServiceTrait 

Source
pub trait AuthorizationServiceTrait: Send + Sync {
    // Required methods
    fn check_authorization<'life0, 'async_trait>(
        &'life0 self,
        request: AuthorizationRequest,
    ) -> Pin<Box<dyn Future<Output = Result<AuthorizationResponse, AuthorizationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn grant_permission_to_role<'life0, 'life1, 'async_trait>(
        &'life0 self,
        role: &'life1 str,
        permission: Permission,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn revoke_permission_from_role<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        role: &'life1 str,
        permission: &'life2 Permission,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn assign_role_to_user<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
        role: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn remove_role_from_user<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
        role: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_user_permissions<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Permission>, AuthorizationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn user_has_permission<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
        permission: &'life2 Permission,
    ) -> Pin<Box<dyn Future<Output = Result<bool, AuthorizationError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Authorization service trait

Required Methods§

Source

fn check_authorization<'life0, 'async_trait>( &'life0 self, request: AuthorizationRequest, ) -> Pin<Box<dyn Future<Output = Result<AuthorizationResponse, AuthorizationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if a user is authorized to perform an action on a resource

Source

fn grant_permission_to_role<'life0, 'life1, 'async_trait>( &'life0 self, role: &'life1 str, permission: Permission, ) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Grant a permission to a role

Source

fn revoke_permission_from_role<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, role: &'life1 str, permission: &'life2 Permission, ) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Revoke a permission from a role

Source

fn assign_role_to_user<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user_id: &'life1 str, role: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Assign a role to a user

Source

fn remove_role_from_user<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user_id: &'life1 str, role: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Remove a role from a user

Source

fn get_user_permissions<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Permission>, AuthorizationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all permissions for a user

Source

fn user_has_permission<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user_id: &'life1 str, permission: &'life2 Permission, ) -> Pin<Box<dyn Future<Output = Result<bool, AuthorizationError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if user has a specific permission

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§