backbone_authorization/
traits.rs1use crate::types::*;
6use async_trait::async_trait;
7
8#[async_trait]
10pub trait AuthorizationServiceTrait: Send + Sync {
11 async fn check_authorization(
13 &self,
14 request: AuthorizationRequest,
15 ) -> Result<AuthorizationResponse, AuthorizationError>;
16
17 async fn grant_permission_to_role(
19 &self,
20 role: &str,
21 permission: Permission,
22 ) -> Result<(), AuthorizationError>;
23
24 async fn revoke_permission_from_role(
26 &self,
27 role: &str,
28 permission: &Permission,
29 ) -> Result<(), AuthorizationError>;
30
31 async fn assign_role_to_user(
33 &self,
34 user_id: &str,
35 role: &str,
36 ) -> Result<(), AuthorizationError>;
37
38 async fn remove_role_from_user(
40 &self,
41 user_id: &str,
42 role: &str,
43 ) -> Result<(), AuthorizationError>;
44
45 async fn get_user_permissions(
47 &self,
48 user_id: &str,
49 ) -> Result<Vec<Permission>, AuthorizationError>;
50
51 async fn user_has_permission(
53 &self,
54 user_id: &str,
55 permission: &Permission,
56 ) -> Result<bool, AuthorizationError>;
57}