Begin new protocol refactor
parent: tbd commit: 26651b1
1 | use Debug; |
2 | |
3 | use |
4 | , | DecodeRsaPrivateKey
5 | , | SigningKey
6 | , | Sha256
7 | , |
8 | RsaPrivateKey, |
9 | ; |
10 | use ; |
11 | use info; |
12 | |
13 | use crate; |
14 | |
15 | use ; |
16 | |
17 | |
18 | |
19 | pub user: User, |
20 | pub generated_for: Instance, |
21 | pub exp: u64, |
22 | |
23 | |
24 | |
25 | |
26 | pub source: , |
27 | pub message: , |
28 | |
29 | |
30 | |
31 | |
32 | pub source: , |
33 | pub payload: , |
34 | |
35 | |
36 | // impl<T: Serialize> From<Authenticated<T>> for AuthenticatedPayload { |
37 | // fn from(mut value: Authenticated<T>) -> Self { |
38 | // let payload = bincode::serialize(&value.message).unwrap(); |
39 | |
40 | // AuthenticatedPayload { |
41 | // target_instance: value.target_instance, |
42 | // source: value |
43 | // .source |
44 | // .drain(..) |
45 | // .map(|provider| provider.as_ref().authenticate(&payload)) |
46 | // .collect::<Vec<_>>(), |
47 | // message_type: value.message_type, |
48 | // payload, |
49 | // } |
50 | // } |
51 | // } |
52 | |
53 | |
54 | ; |
55 | |
56 | |
57 | |
58 | ; |
59 | |
60 | |
61 | |
62 | |
63 | A: AuthenticationSourceProvider, |
64 | |
65 | |
66 | vec! |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | A: AuthenticationSourceProvider, |
73 | B: AuthenticationSourceProvider, |
74 | |
75 | |
76 | let = self; |
77 | |
78 | vec! |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | Self |
85 | source: vec!, |
86 | message, |
87 | |
88 | |
89 | |
90 | |
91 | &mut self, |
92 | authentication: P, |
93 | |
94 | let message_payload = to_vec .unwrap; |
95 | |
96 | info! |
97 | "Verifying payload: {}", |
98 | unwrap | from_utf8 .
99 | ; |
100 | |
101 | self.source |
102 | .push; |
103 | |
104 | |
105 | |
106 | let payload = serialize .unwrap; |
107 | |
108 | AuthenticatedPayload |
109 | source: self |
110 | .source |
111 | .drain |
112 | .map |
113 | ., |
114 | payload, |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | |
122 | |
123 | pub user: User, |
124 | pub token: UserAuthenticationToken, |
125 | |
126 | |
127 | |
128 | |
129 | User |
130 | user: self.user.clone, |
131 | token: self.token.clone, |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | pub instance: Instance, |
139 | pub private_key: String, |
140 | |
141 | |
142 | |
143 | |
144 | let mut rng = thread_rng; |
145 | |
146 | let private_key = from_pkcs1_pem .unwrap; |
147 | let signing_key = new; |
148 | let signature = signing_key.sign_with_rng; |
149 | |
150 | Instance |
151 | instance: self.instance.clone, |
152 | // TODO: Actually parse signature from private key |
153 | signature: InstanceSignature, |
154 | |
155 | |
156 | |
157 | |
158 | |
159 | |
160 | ; |
161 | |
162 | |
163 | |
164 | Self |
165 | |
166 | |
167 | |
168 | |
169 | |
170 | self.0.clone |
171 | |
172 | |
173 | |
174 | |
175 | |
176 | &self.0 |
177 | |
178 | |
179 | |
180 | |
181 | ; |
182 | |
183 | |
184 | |
185 | &self.0 |
186 | |
187 | |
188 | |
189 | |
190 | |
191 | User |
192 | user: User, |
193 | token: UserAuthenticationToken, |
194 | , |
195 | Instance |
196 | instance: Instance, |
197 | signature: InstanceSignature, |
198 | , |
199 | |
200 |