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