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