Fix authenticatio?
parent: tbd commit: 576fa7e
Showing 1 changed file with 9 insertions and 9 deletions
giterated-models/src/model/authenticated.rs
@@ -1,4 +1,4 @@ | ||
1 | use std::{any::type_name, fmt::Debug}; | |
1 | use std::{any::type_name, fmt::Debug, ops::Deref}; | |
2 | 2 | |
3 | 3 | use rsa::{ |
4 | 4 | pkcs1::DecodeRsaPrivateKey, |
@@ -20,9 +20,9 @@ pub struct UserTokenMetadata { | ||
20 | 20 | } |
21 | 21 | |
22 | 22 | #[derive(Debug)] |
23 | pub struct Authenticated<'a, T: Serialize> { | |
23 | pub struct Authenticated<T: Serialize> { | |
24 | 24 | pub target_instance: Option<Instance>, |
25 | pub source: Vec<&'a dyn AuthenticationSourceProvider>, | |
25 | pub source: Vec<Box<dyn AuthenticationSourceProvider>>, | |
26 | 26 | pub message_type: String, |
27 | 27 | pub message: T, |
28 | 28 | } |
@@ -35,8 +35,8 @@ pub struct AuthenticatedPayload { | ||
35 | 35 | pub payload: Vec<u8>, |
36 | 36 | } |
37 | 37 | |
38 | impl<'a, T: Serialize> From<Authenticated<'a, T>> for AuthenticatedPayload { | |
39 | fn from(mut value: Authenticated<'a, T>) -> Self { | |
38 | impl<T: Serialize> From<Authenticated<T>> for AuthenticatedPayload { | |
39 | fn from(mut value: Authenticated<T>) -> Self { | |
40 | 40 | let payload = bincode::serialize(&value.message).unwrap(); |
41 | 41 | |
42 | 42 | AuthenticatedPayload { |
@@ -44,7 +44,7 @@ impl<'a, T: Serialize> From<Authenticated<'a, T>> for AuthenticatedPayload { | ||
44 | 44 | source: value |
45 | 45 | .source |
46 | 46 | .drain(..) |
47 | .map(|provider| provider.authenticate(&payload)) | |
47 | .map(|provider| provider.as_ref().authenticate(&payload)) | |
48 | 48 | .collect::<Vec<_>>(), |
49 | 49 | message_type: value.message_type, |
50 | 50 | payload, |
@@ -81,7 +81,7 @@ where | ||
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | impl<'a, T: Serialize + Debug> Authenticated<'a, T> { | |
84 | impl<T: Serialize + Debug> Authenticated<T> { | |
85 | 85 | pub fn new(message: T) -> Self { |
86 | 86 | Self { |
87 | 87 | source: vec![], |
@@ -109,7 +109,7 @@ impl<'a, T: Serialize + Debug> Authenticated<'a, T> { | ||
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | pub fn append_authentication(&mut self, authentication: &'a dyn AuthenticationSourceProvider) { | |
112 | pub fn append_authentication<P: AuthenticationSourceProvider + 'static>(&mut self, authentication: P) { | |
113 | 113 | let message_payload = serde_json::to_vec(&self.message).unwrap(); |
114 | 114 | |
115 | 115 | info!( |
@@ -117,7 +117,7 @@ impl<'a, T: Serialize + Debug> Authenticated<'a, T> { | ||
117 | 117 | std::str::from_utf8(&message_payload).unwrap() |
118 | 118 | ); |
119 | 119 | |
120 | self.source.push(authentication); | |
120 | self.source.push(Box::new(authentication) as Box<dyn AuthenticationSourceProvider>); | |
121 | 121 | } |
122 | 122 | |
123 | 123 | pub fn into_payload(self) -> AuthenticatedPayload { |