use serde::{Deserialize, Serialize}; use crate::model::authenticated::UserAuthenticationToken; /// An account registration request. /// /// # Authentication /// - Instance Authentication /// - **ONLY ACCEPTED WHEN SAME-INSTANCE** #[derive(Clone, Serialize, Deserialize)] pub struct RegisterAccountRequest { pub username: String, pub email: Option, pub password: String, } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct RegisterAccountResponse { pub token: String, } /// An authentication token request. /// /// AKA Login Request /// /// # Authentication /// - Instance Authentication /// - Identifies the Instance to issue the token for /// # Authorization /// - Credentials ([`crate::backend::AuthBackend`]-based) /// - Identifies the User account to issue a token for /// - Decrypts user private key to issue to #[derive(Clone, Serialize, Deserialize)] pub struct AuthenticationTokenRequest { pub username: String, pub password: String, } #[derive(Clone, Serialize, Deserialize)] pub struct AuthenticationTokenResponse { pub token: String, } /// An authentication token extension request. /// /// # Authentication /// - Instance Authentication /// - Identifies the Instance to issue the token for /// - User Authentication /// - Authenticates the validity of the token /// # Authorization /// - Token-based /// - Validates authorization using token's authenticity #[derive(Clone, Serialize, Deserialize)] pub struct TokenExtensionRequest { pub token: UserAuthenticationToken, } #[derive(Clone, Serialize, Deserialize)] pub struct TokenExtensionResponse { pub new_token: Option, }