actix_jwt_auth_middleware/use_jwt/
resource.rs1use crate::AuthenticationService;
2use crate::Authority;
3
4use actix_web::dev::ServiceFactory;
5use actix_web::dev::ServiceRequest;
6use actix_web::dev::ServiceResponse;
7use actix_web::Error as ActixWebError;
8use actix_web::FromRequest;
9use actix_web::Handler;
10use actix_web::Resource;
11use jwt_compact::Algorithm as JWTAlgorithm;
12use serde::de::DeserializeOwned;
13use serde::Serialize;
14
15pub trait UseJWTOnResource<Claims, Algorithm, ReAuth, Args>
21where
22 Claims: Serialize + DeserializeOwned + 'static,
23 Algorithm: JWTAlgorithm + Clone,
24 Algorithm::SigningKey: Clone,
25 ReAuth: Handler<Args, Output = Result<(), ActixWebError>>,
26 Args: FromRequest,
27{
28 fn use_jwt(
35 self,
36 authority: Authority<Claims, Algorithm, ReAuth, Args>,
37 ) -> Resource<
38 impl ServiceFactory<
39 ServiceRequest,
40 Config = (),
41 Response = ServiceResponse,
42 Error = ActixWebError,
43 InitError = (),
44 >,
45 >;
46}
47
48impl<Claims, Algorithm, ReAuth, Args> UseJWTOnResource<Claims, Algorithm, ReAuth, Args> for Resource
49where
50 Claims: Serialize + DeserializeOwned + 'static,
51 Algorithm: JWTAlgorithm + Clone + 'static,
52 Algorithm::SigningKey: Clone,
53 ReAuth: Handler<Args, Output = Result<(), ActixWebError>>,
54 Args: FromRequest + 'static,
55{
56 fn use_jwt(
57 self,
58 authority: Authority<Claims, Algorithm, ReAuth, Args>,
59 ) -> Resource<
60 impl ServiceFactory<
61 ServiceRequest,
62 Config = (),
63 Response = ServiceResponse,
64 Error = ActixWebError,
65 InitError = (),
66 >,
67 > {
68 self.wrap(AuthenticationService::new(authority))
69 }
70}