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

ambee/giterated

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

Major post-refactor cleanup

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨f90d7fb

⁨src/messages/authentication.rs⁩ - ⁨1684⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::authenticated::UserAuthenticationToken;
4
5 /// An account registration request.
6 ///
7 /// # Authentication
8 /// - Instance Authentication
9 /// - **ONLY ACCEPTED WHEN SAME-INSTANCE**
10 #[derive(Clone, Serialize, Deserialize)]
11 pub struct RegisterAccountRequest {
12 pub username: String,
13 pub email: Option<String>,
14 pub password: String,
15 }
16
17 #[derive(Clone, Debug, Serialize, Deserialize)]
18 pub struct RegisterAccountResponse {
19 pub token: String,
20 }
21
22 /// An authentication token request.
23 ///
24 /// AKA Login Request
25 ///
26 /// # Authentication
27 /// - Instance Authentication
28 /// - Identifies the Instance to issue the token for
29 /// # Authorization
30 /// - Credentials ([`crate::backend::AuthBackend`]-based)
31 /// - Identifies the User account to issue a token for
32 /// - Decrypts user private key to issue to
33 #[derive(Clone, Serialize, Deserialize)]
34 pub struct AuthenticationTokenRequest {
35 pub username: String,
36 pub password: String,
37 }
38
39 #[derive(Clone, Serialize, Deserialize)]
40 pub struct AuthenticationTokenResponse {
41 pub token: UserAuthenticationToken,
42 }
43
44 /// An authentication token extension request.
45 ///
46 /// # Authentication
47 /// - Instance Authentication
48 /// - Identifies the Instance to issue the token for
49 /// - User Authentication
50 /// - Authenticates the validity of the token
51 /// # Authorization
52 /// - Token-based
53 /// - Validates authorization using token's authenticity
54 #[derive(Clone, Serialize, Deserialize)]
55 pub struct TokenExtensionRequest {
56 pub token: UserAuthenticationToken,
57 }
58
59 #[derive(Clone, Serialize, Deserialize)]
60 pub struct TokenExtensionResponse {
61 pub new_token: Option<String>,
62 }
63