Fixes for authentication!
parent: tbd commit: 969964d
1 | use Error; |
2 | use Error; |
3 | |
4 | use crate |
5 | AuthenticationTokenRequest, RegisterAccountRequest, TokenExtensionRequest, |
6 | ; |
7 | use crate; |
8 | use crate; |
9 | |
10 | use ConnectionState; |
11 | |
12 | pub async |
13 | message_type: &str, |
14 | message: &NetworkMessage, |
15 | state: &ConnectionState, |
16 | |
17 | match message_type |
18 | "&giterated_daemon::messages::authentication::RegisterAccountRequest" => |
19 | register_account_request |
20 | .handle_message |
21 | .await?; |
22 | |
23 | Ok |
24 | |
25 | "&giterated_daemon::messages::authentication::AuthenticationTokenRequest" => |
26 | authentication_token_request |
27 | .handle_message |
28 | .await?; |
29 | |
30 | Ok |
31 | |
32 | "&giterated_daemon::messages::authentication::TokenExtensionRequest" => |
33 | token_extension_request |
34 | .handle_message |
35 | .await?; |
36 | |
37 | Ok |
38 | |
39 | _ => Ok, |
40 | |
41 | |
42 | |
43 | async |
44 | State | : ,
45 | Message | : ,
46 | instance: AuthenticatedInstance, |
47 | |
48 | if *instance.inner != connection_state.instance |
49 | return Err; |
50 | |
51 | |
52 | let mut user_backend = connection_state.user_backend.lock .await; |
53 | |
54 | let response = user_backend |
55 | .register |
56 | .await |
57 | .map_err?; |
58 | drop; |
59 | |
60 | connection_state |
61 | .send |
62 | .await |
63 | .map_err?; |
64 | |
65 | Ok |
66 | |
67 | |
68 | async |
69 | State | : ,
70 | Message | : ,
71 | instance: AuthenticatedInstance, |
72 | |
73 | let issued_for = instance.inner .clone; |
74 | |
75 | let mut token_granter = connection_state.auth_granter.lock .await; |
76 | |
77 | let response = token_granter |
78 | .token_request |
79 | .await |
80 | .map_err?; |
81 | |
82 | connection_state |
83 | .send |
84 | .await |
85 | .map_err?; |
86 | |
87 | Ok |
88 | |
89 | |
90 | async |
91 | State | : ,
92 | Message | : ,
93 | instance: AuthenticatedInstance, |
94 | |
95 | let issued_for = instance.inner .clone; |
96 | |
97 | let mut token_granter = connection_state.auth_granter.lock .await; |
98 | |
99 | let response = token_granter |
100 | .extension_request |
101 | .await |
102 | .map_err?; |
103 | |
104 | connection_state |
105 | .send |
106 | .await |
107 | .map_err?; |
108 | |
109 | Ok |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | InvalidRequest, |
116 | |
117 | SameInstance, |
118 | |
119 | Registration, |
120 | |
121 | Sending, |
122 | |
123 | TokenIssuance, |
124 | |
125 |