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

ambee/giterated

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

Add token extension

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨86d028f

⁨src/messages/authentication.rs⁩ - ⁨1112⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use super::InstanceAuthenticated;
4
5 #[derive(Clone, Serialize, Deserialize)]
6 pub enum AuthenticationMessage {
7 Request(AuthenticationRequest),
8 Response(AuthenticationResponse),
9 }
10
11 #[derive(Clone, Serialize, Deserialize)]
12 pub enum AuthenticationRequest {
13 AuthenticationToken(AuthenticationTokenRequest),
14 TokenExtension(InstanceAuthenticated<TokenExtensionRequest>),
15 }
16
17 #[derive(Clone, Serialize, Deserialize)]
18 pub enum AuthenticationResponse {
19 AuthenticationToken(AuthenticationTokenResponse),
20 TokenExtension(TokenExtensionResponse),
21 }
22
23 #[derive(Clone, Serialize, Deserialize)]
24 pub struct AuthenticationTokenRequest {
25 pub secret_key: String,
26 pub username: String,
27 pub password: String,
28 }
29
30 #[derive(Clone, Serialize, Deserialize)]
31 pub struct AuthenticationTokenResponse {
32 pub token: String,
33 }
34
35 #[derive(Clone, Serialize, Deserialize)]
36 pub struct TokenExtensionRequest {
37 pub secret_key: String,
38 pub token: String,
39 }
40
41 #[derive(Clone, Serialize, Deserialize)]
42 pub struct TokenExtensionResponse {
43 pub new_token: Option<String>,
44 }
45