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

ambee/giterated

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

Change forwarding

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨2556801

⁨giterated-models/src/messages/authentication.rs⁩ - ⁨1769⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::{authenticated::UserAuthenticationToken, instance::Instance};
4
5 /// An account registration request.
6 ///
7 /// # Authentication
8 /// - Instance Authentication
9 /// - **ONLY ACCEPTED WHEN SAME-INSTANCE**
10 #[derive(Clone, Debug, 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, Debug, Serialize, Deserialize)]
34 pub struct AuthenticationTokenRequest {
35 pub instance: Instance,
36 pub username: String,
37 pub password: String,
38 }
39
40 #[derive(Clone, Debug, Serialize, Deserialize)]
41 pub struct AuthenticationTokenResponse {
42 pub token: UserAuthenticationToken,
43 }
44
45 /// An authentication token extension request.
46 ///
47 /// # Authentication
48 /// - Instance Authentication
49 /// - Identifies the Instance to issue the token for
50 /// - User Authentication
51 /// - Authenticates the validity of the token
52 /// # Authorization
53 /// - Token-based
54 /// - Validates authorization using token's authenticity
55 #[derive(Clone, Debug, Serialize, Deserialize)]
56 pub struct TokenExtensionRequest {
57 pub token: UserAuthenticationToken,
58 }
59
60 #[derive(Clone, Debug, Serialize, Deserialize)]
61 pub struct TokenExtensionResponse {
62 pub new_token: Option<String>,
63 }
64