JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Revert authentication payload change

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨16b4bc2

⁨giterated-models/src/messages/authentication.rs⁩ - ⁨2178⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::{authenticated::UserAuthenticationToken, instance::Instance};
4
5 use super::MessageTarget;
6
7 /// An account registration request.
8 ///
9 /// # Authentication
10 /// - Instance Authentication
11 /// - **ONLY ACCEPTED WHEN SAME-INSTANCE**
12 #[derive(Clone, Debug, Serialize, Deserialize)]
13 pub struct RegisterAccountRequest {
14 pub username: String,
15 pub email: Option<String>,
16 pub password: String,
17 }
18
19 impl MessageTarget for RegisterAccountRequest {
20 fn target(&self) -> Option<Instance> {
21 None
22 }
23 }
24
25 #[derive(Clone, Debug, Serialize, Deserialize)]
26 pub struct RegisterAccountResponse {
27 pub token: String,
28 }
29
30 /// An authentication token request.
31 ///
32 /// AKA Login Request
33 ///
34 /// # Authentication
35 /// - Instance Authentication
36 /// - Identifies the Instance to issue the token for
37 /// # Authorization
38 /// - Credentials ([`crate::backend::AuthBackend`]-based)
39 /// - Identifies the User account to issue a token for
40 /// - Decrypts user private key to issue to
41 #[derive(Clone, Debug, Serialize, Deserialize)]
42 pub struct AuthenticationTokenRequest {
43 pub instance: Instance,
44 pub username: String,
45 pub password: String,
46 }
47
48 impl MessageTarget for AuthenticationTokenRequest {
49 fn target(&self) -> Option<Instance> {
50 Some(self.instance.clone())
51 }
52 }
53
54 #[derive(Clone, Debug, Serialize, Deserialize)]
55 pub struct AuthenticationTokenResponse {
56 pub token: UserAuthenticationToken,
57 }
58
59 /// An authentication token extension request.
60 ///
61 /// # Authentication
62 /// - Instance Authentication
63 /// - Identifies the Instance to issue the token for
64 /// - User Authentication
65 /// - Authenticates the validity of the token
66 /// # Authorization
67 /// - Token-based
68 /// - Validates authorization using token's authenticity
69 #[derive(Clone, Debug, Serialize, Deserialize)]
70 pub struct TokenExtensionRequest {
71 pub token: UserAuthenticationToken,
72 }
73
74 impl MessageTarget for TokenExtensionRequest {
75 fn target(&self) -> Option<Instance> {
76 // todo!
77 None
78 }
79 }
80
81 #[derive(Clone, Debug, Serialize, Deserialize)]
82 pub struct TokenExtensionResponse {
83 pub new_token: Option<String>,
84 }
85