next_web_dev/security/
authorization_service.rs

1use async_trait::async_trait;
2
3use super::login_type::LoginType;
4
5#[async_trait]
6pub trait AuthorizationService<V: IntoIterator<Item = String>>: Send + Sync + 'static {
7
8    /// Returns the roles of the user with the given `user_id` and `login_type`.
9    async fn user_role(&self, user_id: &String, login_type: &LoginType) -> V;
10
11    /// Returns the permission of the user with the given `user_id` and `login_type`.
12    async fn user_permission(&self, user_id: &String, login_type: &LoginType) -> V;
13
14    /// Verifies the token of the user with the given `user_id` and `login_type`.
15    async fn verify_token(&self, user_id: &String, login_type: &LoginType) -> bool;
16}