Huge refactor to prep for moving the daemon over to the plugin architecture
parent: tbd commit: 5df753c
1 | |
2 | |
3 | pub use *; |
4 | pub use *; |
5 | |
6 | pub use *; |
7 | |
8 | |
9 | pub use *; |
10 | |
11 | use ; |
12 | pub use *; |
13 | pub use *; |
14 | |
15 | |
16 | // Temp pub use to figure out what's important |
17 | |
18 | pub use Error; |
19 | pub use *; |
20 | pub use ; |
21 | pub use Instance; |
22 | pub use GiteratedObject; |
23 | pub use GiteratedOperation; |
24 | pub use User; |
25 | |
26 | |
27 | use ; |
28 | |
29 | use Debug; |
30 | use |
31 | , |
32 | |
33 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
34 | , |
35 | , | GiteratedObject
36 | , | ObjectBackend
37 | , | GiteratedOperation
38 | , |
39 | , |
40 | , | User
41 | , |
42 | ; |
43 | |
44 | |
45 | |
46 | pub object_name: &'a str, |
47 | pub operation_name: &'a str, |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | Self |
54 | object_name: object_name, |
55 | operation_name: operation_name, |
56 | |
57 | |
58 | |
59 | |
60 | |
61 | |
62 | pub object_kind: &'a str, |
63 | pub value_kind: &'a str, |
64 | |
65 | |
66 | |
67 | |
68 | Self |
69 | object_kind: object_name, |
70 | value_kind: value_name, |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | |
77 | pub object_kind: &'a str, |
78 | pub setting_name: &'a str, |
79 | |
80 | |
81 | |
82 | |
83 | Self |
84 | object_kind: object_name, |
85 | setting_name: name, |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | type Error: ; |
93 | |
94 | async |
95 | object: &O, |
96 | operation: &D, |
97 | state: &StackOperationState, |
98 | ; |
99 | |
100 | |
101 | |
102 | |
103 | for StackOperationState |
104 | |
105 | type Error = Infallible; |
106 | |
107 | async |
108 | _object: &O, |
109 | _operation: &D, |
110 | state: &StackOperationState, |
111 | |
112 | Ok |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | ; |
119 | |
120 | |
121 | |
122 | for AuthenticatedUser |
123 | |
124 | type Error = MissingValue; |
125 | |
126 | async |
127 | _object: &O, |
128 | _operation: &D, |
129 | state: &StackOperationState, |
130 | |
131 | state |
132 | .user |
133 | .clone |
134 | .ok_or |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | for AuthenticatedInstance |
141 | |
142 | type Error = MissingValue; |
143 | |
144 | async |
145 | _object: &O, |
146 | _operation: &D, |
147 | state: &StackOperationState, |
148 | |
149 | state |
150 | .instance |
151 | .clone |
152 | .ok_or |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | T: + Send + Sync, |
159 | O: GiteratedObject + Sync, |
160 | D: + Send + Sync, |
161 | > |
162 | |
163 | type Error = Infallible; |
164 | |
165 | async |
166 | object: &O, |
167 | operation: &D, |
168 | state: &StackOperationState, |
169 | |
170 | Ok |
171 | |
172 | |
173 | |
174 | |
175 | ; |
176 | |
177 | |
178 | ; |
179 | |
180 | |
181 | |
182 | type Error: ; |
183 | |
184 | async |
185 | &self, |
186 | authorize_for: &O, |
187 | state: &StackOperationState, |
188 | ; |
189 | |
190 | |
191 | |
192 | |
193 | type Error = Error; |
194 | |
195 | async |
196 | &self, |
197 | authorize_for: &O, |
198 | operation_state: &StackOperationState, |
199 | |
200 | Ok |
201 | .runtime |
202 | . |
203 | .await |
204 | .is_ok |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | type Error = MissingValue; |
211 | |
212 | async |
213 | &self, |
214 | authorize_for: &User, |
215 | operation_state: &StackOperationState, |
216 | |
217 | let authenticated_user = operation_state |
218 | .user |
219 | .as_ref |
220 | .ok_or?; |
221 | |
222 | Ok |
223 | |
224 | |
225 | |
226 | |
227 | |
228 | type Error = MissingValue; |
229 | |
230 | async |
231 | &self, |
232 | authorize_for: &User, |
233 | operation_state: &StackOperationState, |
234 | |
235 | let authenticated_user = operation_state |
236 | .user |
237 | .as_ref |
238 | .ok_or?; |
239 | |
240 | Ok |
241 | |
242 | |
243 | |
244 | |
245 | |
246 | type Error = Error; |
247 | |
248 | async |
249 | &self, |
250 | authorize_for: &Repository, |
251 | operation_state: &StackOperationState, |
252 | |
253 | let authenticated_user = operation_state |
254 | .user |
255 | .as_ref |
256 | .ok_or_else?; |
257 | |
258 | let mut object = operation_state |
259 | .runtime |
260 | . |
261 | .await |
262 | .map_err?; |
263 | |
264 | let access_list = object |
265 | . |
266 | .await |
267 | .map_err?; |
268 | |
269 | if access_list |
270 | .0 |
271 | .iter |
272 | .any |
273 | |
274 | Ok |
275 | else |
276 | Ok |
277 | |
278 | |
279 | |
280 | |
281 | |
282 | |
283 | type Error = Error; |
284 | |
285 | async |
286 | &self, |
287 | authorize_for: &Repository, |
288 | operation_state: &StackOperationState, |
289 | |
290 | let authenticated_user = operation_state |
291 | .user |
292 | .as_ref |
293 | .ok_or_else?; |
294 | |
295 | let mut object = operation_state |
296 | .runtime |
297 | . |
298 | .await |
299 | .map_err?; |
300 | |
301 | let access_list = object |
302 | . |
303 | .await |
304 | .map_err?; |
305 | |
306 | if access_list |
307 | .0 |
308 | .iter |
309 | .any |
310 | |
311 | Ok |
312 | else |
313 | Ok |
314 | |
315 | |
316 | |
317 | |
318 | |
319 | |
320 | type Error = Infallible; |
321 | |
322 | async |
323 | &self, |
324 | authorize_for: &Instance, |
325 | state: &StackOperationState, |
326 | |
327 | if state.our_instance == *authorize_for |
328 | Ok |
329 | else |
330 | Ok |
331 | |
332 | |
333 | |
334 | |
335 | |
336 | |
337 | type Error = Infallible; |
338 | |
339 | async |
340 | &self, |
341 | authorize_for: &Instance, |
342 | state: &StackOperationState, |
343 | |
344 | if state.our_instance == *authorize_for |
345 | Ok |
346 | else |
347 | Ok |
348 | |
349 | |
350 | |
351 | |
352 | |
353 | |
354 | type Error = Infallible; |
355 | |
356 | async |
357 | &self, |
358 | authorize_for: &Instance, |
359 | state: &StackOperationState, |
360 | |
361 | if state.our_instance == *authorize_for |
362 | Ok |
363 | else |
364 | Ok |
365 | |
366 | |
367 | |
368 | |
369 | |
370 | |
371 | type Error = UnauthorizedError; |
372 | |
373 | async |
374 | object: &User, |
375 | operation: &A, |
376 | state: &StackOperationState, |
377 | |
378 | // TODO |
379 | let authenticated = from_state |
380 | .await |
381 | .map_err?; |
382 | |
383 | match operation.authorize .await |
384 | Ok => |
385 | assert!; |
386 | |
387 | Err => return Err, |
388 | ; |
389 | |
390 | Ok |
391 | |
392 | |
393 | |
394 | |
395 | |
396 | for AuthorizedInstance |
397 | |
398 | type Error = UnauthorizedError; |
399 | |
400 | async |
401 | object: &Instance, |
402 | operation: &A, |
403 | state: &StackOperationState, |
404 | |
405 | //TODO |
406 | let authenticated = from_state |
407 | .await |
408 | .map_err?; |
409 | |
410 | match operation.authorize .await |
411 | Ok => |
412 | assert!; |
413 | |
414 | Err => return Err, |
415 | ; |
416 | |
417 | Ok |
418 | |
419 | |
420 | |
421 | |
422 | |
423 | pub our_instance: Instance, |
424 | pub instance: , |
425 | pub user: , |
426 | |
427 | |
428 | |
429 | ; |
430 | |
431 | |
432 | |
433 | AuthenticatedInstance |
434 | |
435 | |
436 | |
437 | |
438 | type Target = Instance; |
439 | |
440 | |
441 | &self.0 |
442 | |
443 | |
444 | |
445 | |
446 | ; |
447 | |
448 | |
449 | |
450 | AuthenticatedUser |
451 | |
452 | |
453 | |
454 | |
455 | type Target = User; |
456 | |
457 | |
458 | &self.0 |
459 | |
460 | |
461 | |
462 | |
463 | |
464 | |
465 | ; |
466 | |
467 | |
468 | |
469 | O: GiteratedObject, |
470 | S: Setting + Serialize + DeserializeOwned, |
471 | |
472 | type Success = ; |
473 | |
474 | type Failure = ; |
475 | |
476 | |
477 | ; |
478 | |
479 | |
480 | |
481 | type Error = MissingValue; |
482 | |
483 | async |
484 | _required_parameters: &P, |
485 | operation_state: &OS, |
486 | |
487 | Ok |
488 | |
489 | |
490 |