actix_web_security/authentication/scheme/
authentication_provider.rs1use async_trait::async_trait;
4
5use crate::authentication::error::error_type::AuthenticationError;
6use crate::authentication::scheme::authentication::Authentication;
7use crate::user_details::UserDetails;
8
9#[async_trait]
12pub trait AuthenticationProvider: AuthenticationProviderClone {
13 #[allow(clippy::borrowed_box)]
14 async fn authenticate(
15 &self,
16 authentication: &Box<dyn Authentication>,
17 ) -> Result<Box<dyn UserDetails>, AuthenticationError>;
18}
19
20pub trait AuthenticationProviderClone: Send + Sync {
23 fn clone_box(&self) -> Box<dyn AuthenticationProvider>;
24}
25
26impl<U> AuthenticationProviderClone for U
27where
28 U: 'static + AuthenticationProvider + Clone,
29{
30 fn clone_box(&self) -> Box<dyn AuthenticationProvider> {
31 Box::new(self.clone())
32 }
33}
34
35impl Clone for Box<dyn AuthenticationProvider> {
36 fn clone(&self) -> Self {
37 self.clone_box()
38 }
39}