Fixed imports!
parent: tbd commit: ef0e853
1 | use Error; |
2 | use Future; |
3 | |
4 | use Instance; |
5 | |
6 | use User; |
7 | |
8 | use |
9 | AuthenticatedPayload, AuthenticationSource, UserTokenMetadata, |
10 | ; |
11 | use ; |
12 | use |
13 | , | DecodeRsaPublicKey
14 | , |
15 | , | Sha256
16 | , | Verifier
17 | RsaPublicKey, |
18 | ; |
19 | use ; |
20 | use ; |
21 | |
22 | use crate ConnectionState; |
23 | |
24 | ; |
25 | |
26 | |
27 | type Target = ; |
28 | |
29 | |
30 | &self.0 |
31 | |
32 | |
33 | |
34 | ; |
35 | |
36 | |
37 | |
38 | |
39 | Missing, |
40 | // #[error("{0}")] |
41 | // InstanceAuthentication(#[from] Error), |
42 | |
43 | InvalidToken, |
44 | |
45 | Other, |
46 | |
47 | |
48 | ; |
49 | |
50 | |
51 | |
52 | &self.0 |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | async ; |
59 | |
60 | |
61 | |
62 | |
63 | async |
64 | network_message: &NetworkMessage, |
65 | state: &ConnectionState, |
66 | |
67 | let message: AuthenticatedPayload = |
68 | map_err?; | from_slice .
69 | |
70 | let = message |
71 | .source |
72 | .iter |
73 | .filter_map |
74 | if let User = auth |
75 | Some |
76 | else |
77 | None |
78 | |
79 | |
80 | .next |
81 | .ok_or_else?; |
82 | |
83 | let authenticated_instance = |
84 | ?; | from_message .await
85 | |
86 | let public_key_raw = state.public_key .await?; |
87 | let verification_key = from_rsa_pem .unwrap; |
88 | |
89 | let data: = decode |
90 | auth_token.as_ref, |
91 | &verification_key, |
92 | & new, |
93 | |
94 | .unwrap; |
95 | |
96 | if data.claims.user != *auth_user |
97 | || data.claims.generated_for != *authenticated_instance.inner |
98 | |
99 | Err |
100 | else |
101 | Ok |
102 | |
103 | |
104 | |
105 | |
106 | |
107 | |
108 | async |
109 | network_message: &NetworkMessage, |
110 | state: &ConnectionState, |
111 | |
112 | let message: AuthenticatedPayload = |
113 | map_err?; | from_slice .
114 | |
115 | info!; |
116 | |
117 | let = message |
118 | .source |
119 | .iter |
120 | .filter_map |
121 | if let Instance |
122 | instance, |
123 | signature, |
124 | = auth |
125 | |
126 | Some |
127 | else |
128 | None |
129 | |
130 | |
131 | .next |
132 | // TODO: Instance authentication error |
133 | .ok_or_else?; |
134 | |
135 | info!; |
136 | |
137 | info!; |
138 | |
139 | let public_key = from_pkcs1_pem .unwrap; |
140 | |
141 | let verifying_key: = new; |
142 | |
143 | verifying_key.verify |
144 | &message.payload, |
145 | & try_from .unwrap, |
146 | ?; |
147 | |
148 | Ok |
149 | |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | T: , |
156 | S: Send + Sync + 'static, |
157 | |
158 | async |
159 | Ok |
160 | |
161 | |
162 | |
163 | |
164 | |
165 | async ; |
166 | |
167 | |
168 | |
169 | |
170 | T: FnOnce(T1) -> F + Clone + Send + 'static, |
171 | F: + Send, |
172 | T1: + Send, |
173 | S: Send + Sync, |
174 | E: Error + Send + Sync + 'static, |
175 | |
176 | async |
177 | let value = T1 from_message .await?; |
178 | self .await.map_err |
179 | |
180 | |
181 | |
182 | |
183 | |
184 | |
185 | T: FnOnce(T1, T2) -> F + Clone + Send + 'static, |
186 | F: + Send, |
187 | T1: + Send, |
188 | T2: + Send, |
189 | S: Send + Sync, |
190 | E: Error + Send + Sync + 'static, |
191 | |
192 | async |
193 | let value = T1 from_message .await?; |
194 | let value_2 = T2 from_message .await?; |
195 | self .await.map_err |
196 | |
197 | |
198 | |
199 | |
200 | |
201 | |
202 | T: FnOnce(T1, T2, T3) -> F + Clone + Send + 'static, |
203 | F: + Send, |
204 | T1: + Send, |
205 | T2: + Send, |
206 | T3: + Send, |
207 | S: Send + Sync, |
208 | E: Error + Send + Sync + 'static, |
209 | |
210 | async |
211 | let value = T1 from_message .await?; |
212 | let value_2 = T2 from_message .await?; |
213 | let value_3 = T3 from_message .await?; |
214 | |
215 | self |
216 | .await |
217 | .map_err |
218 | |
219 | |
220 | |
221 | ; |
222 | |
223 | |
224 | |
225 | |
226 | T: Clone + Send + Sync, |
227 | |
228 | async |
229 | Ok |
230 | |
231 | |
232 | |
233 | // Temp |
234 | |
235 | |
236 | |
237 | T: DeserializeOwned + Send + Sync + Serialize + Debug, |
238 | S: Clone + Send + Sync, |
239 | |
240 | async |
241 | let payload: AuthenticatedPayload = from_slice?; |
242 | let payload = deserialize?; |
243 | |
244 | info!; |
245 | |
246 | Ok |
247 | |
248 | |
249 | |
250 | ; |
251 | |
252 | /// Handshake-specific message type. |
253 | /// |
254 | /// Uses basic serde_json-based deserialization to maintain the highest |
255 | /// level of compatibility across versions. |
256 | ; |
257 | |
258 | |
259 | |
260 | |
261 | T: DeserializeOwned + Send + Sync + Serialize, |
262 | S: Clone + Send + Sync, |
263 | |
264 | async |
265 | Ok |
266 | |
267 | |
268 |