Changes
parent: tbd commit: 0b2a26d
1 | use ; |
2 | |
3 | use Duration; |
4 | use ; |
5 | use ; |
6 | use ; |
7 | use Table; |
8 | |
9 | use crate:: |
10 | , |
11 | , |
12 | ; |
13 | |
14 | |
15 | |
16 | user: User, |
17 | generated_for: Instance, |
18 | exp: u64, |
19 | |
20 | |
21 | |
22 | pub config: Table, |
23 | |
24 | |
25 | |
26 | pub async |
27 | &mut self, |
28 | request: AuthenticationTokenRequest, |
29 | |
30 | let secret_key = self.config |
31 | .as_str |
32 | .unwrap; |
33 | let private_key = |
34 | let mut file = open |
35 | .await |
36 | .unwrap; |
37 | |
38 | let mut key = vec!; |
39 | file.read_to_end .await.unwrap; |
40 | |
41 | key |
42 | ; |
43 | |
44 | if request.secret_key != secret_key |
45 | error!; |
46 | |
47 | panic! |
48 | |
49 | |
50 | let encoding_key = from_rsa_pem .unwrap; |
51 | |
52 | let claims = UserTokenMetadata |
53 | user: User |
54 | username: String from, |
55 | instance: Instance |
56 | url: String from, |
57 | , |
58 | , |
59 | generated_for: Instance |
60 | url: String from, |
61 | , |
62 | exp: |
63 | + from_secs |
64 | .as_secs, |
65 | ; |
66 | |
67 | let token = encode |
68 | & new, |
69 | &claims, |
70 | &encoding_key, |
71 | |
72 | .unwrap; |
73 | |
74 | Ok |
75 | |
76 | |
77 |