pub trait AuthService: Send + Sync {
Show 15 methods
// Required methods
async fn login(&self, credentials: &Credentials) -> AuthResult<AuthToken>;
async fn logout(&self, token: &str) -> AuthResult<()>;
async fn refresh_token(&self, refresh_token: &str) -> AuthResult<AuthToken>;
async fn validate_token(&self, token: &str) -> AuthResult<TokenValidation>;
async fn create_user(
&self,
request: &CreateUserRequest,
) -> AuthResult<UserInfo>;
async fn get_user(&self, user_id: &str) -> AuthResult<UserInfo>;
async fn update_user(
&self,
user_id: &str,
request: &UpdateUserRequest,
) -> AuthResult<UserInfo>;
async fn delete_user(&self, user_id: &str) -> AuthResult<()>;
async fn change_password(
&self,
user_id: &str,
request: &ChangePasswordRequest,
) -> AuthResult<()>;
async fn reset_password(&self, identifier: &str) -> AuthResult<()>;
async fn check_permission(
&self,
user_id: &str,
permission: &str,
) -> AuthResult<bool>;
async fn get_user_roles(&self, user_id: &str) -> AuthResult<Vec<Role>>;
async fn assign_role(&self, user_id: &str, role_id: &str) -> AuthResult<()>;
async fn remove_role(&self, user_id: &str, role_id: &str) -> AuthResult<()>;
fn config(&self) -> &AuthConfig;
}Expand description
认证服务 trait
Required Methods§
Sourceasync fn login(&self, credentials: &Credentials) -> AuthResult<AuthToken>
async fn login(&self, credentials: &Credentials) -> AuthResult<AuthToken>
Sourceasync fn refresh_token(&self, refresh_token: &str) -> AuthResult<AuthToken>
async fn refresh_token(&self, refresh_token: &str) -> AuthResult<AuthToken>
Sourceasync fn validate_token(&self, token: &str) -> AuthResult<TokenValidation>
async fn validate_token(&self, token: &str) -> AuthResult<TokenValidation>
Sourceasync fn create_user(&self, request: &CreateUserRequest) -> AuthResult<UserInfo>
async fn create_user(&self, request: &CreateUserRequest) -> AuthResult<UserInfo>
Sourceasync fn get_user(&self, user_id: &str) -> AuthResult<UserInfo>
async fn get_user(&self, user_id: &str) -> AuthResult<UserInfo>
Sourceasync fn update_user(
&self,
user_id: &str,
request: &UpdateUserRequest,
) -> AuthResult<UserInfo>
async fn update_user( &self, user_id: &str, request: &UpdateUserRequest, ) -> AuthResult<UserInfo>
Sourceasync fn delete_user(&self, user_id: &str) -> AuthResult<()>
async fn delete_user(&self, user_id: &str) -> AuthResult<()>
Sourceasync fn change_password(
&self,
user_id: &str,
request: &ChangePasswordRequest,
) -> AuthResult<()>
async fn change_password( &self, user_id: &str, request: &ChangePasswordRequest, ) -> AuthResult<()>
Sourceasync fn reset_password(&self, identifier: &str) -> AuthResult<()>
async fn reset_password(&self, identifier: &str) -> AuthResult<()>
Sourceasync fn check_permission(
&self,
user_id: &str,
permission: &str,
) -> AuthResult<bool>
async fn check_permission( &self, user_id: &str, permission: &str, ) -> AuthResult<bool>
Sourceasync fn get_user_roles(&self, user_id: &str) -> AuthResult<Vec<Role>>
async fn get_user_roles(&self, user_id: &str) -> AuthResult<Vec<Role>>
Sourceasync fn assign_role(&self, user_id: &str, role_id: &str) -> AuthResult<()>
async fn assign_role(&self, user_id: &str, role_id: &str) -> AuthResult<()>
Sourceasync fn remove_role(&self, user_id: &str, role_id: &str) -> AuthResult<()>
async fn remove_role(&self, user_id: &str, role_id: &str) -> AuthResult<()>
Sourcefn config(&self) -> &AuthConfig
fn config(&self) -> &AuthConfig
获取配置
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.