actix_web_security/authentication/scheme/bearer/jwt/
user_details_service.rs1use async_trait::async_trait;
4use downcast_rs::impl_downcast;
5use downcast_rs::Downcast;
6
7use crate::authentication::scheme::bearer::jwt::Claims;
8use crate::user_details::UserDetails;
9
10#[async_trait]
15pub trait JwtUserDetailsService: Downcast + JwtUserDetailsServiceClone {
16 #[allow(clippy::borrowed_box)]
17 async fn find_user(&self, token: &Box<dyn Claims>) -> Option<Box<dyn UserDetails>>;
18}
19impl_downcast!(JwtUserDetailsService);
20
21pub trait JwtUserDetailsServiceClone: Send + Sync {
22 fn clone_box(&self) -> Box<dyn JwtUserDetailsService>;
23}
24
25impl<U> JwtUserDetailsServiceClone for U
28where
29 U: 'static + JwtUserDetailsService + Clone,
30{
31 fn clone_box(&self) -> Box<dyn JwtUserDetailsService> {
32 Box::new(self.clone())
33 }
34}
35
36impl Clone for Box<dyn JwtUserDetailsService> {
37 fn clone(&self) -> Self {
38 self.clone_box()
39 }
40}