diff --git a/giterated-daemon/src/connection/forwarded.rs b/giterated-daemon/src/connection/forwarded.rs index 01a3d20..f4409ab 100644 --- a/giterated-daemon/src/connection/forwarded.rs +++ b/giterated-daemon/src/connection/forwarded.rs @@ -1,13 +1,13 @@ use futures_util::{SinkExt, StreamExt}; use giterated_api::DaemonConnectionPool; -use giterated_models::{messages::error::ConnectionError, model::authenticated::{Authenticated, AuthenticatedPayload}}; +use giterated_models::{ + messages::error::ConnectionError, + model::authenticated::{Authenticated, AuthenticatedPayload}, +}; use serde::Serialize; use tokio_tungstenite::tungstenite::Message; -pub async fn wrap_forwarded( - pool: &DaemonConnectionPool, - message: AuthenticatedPayload, -) -> Message { +pub async fn wrap_forwarded(pool: &DaemonConnectionPool, message: AuthenticatedPayload) -> Message { let connection = pool.get().await; let mut connection = match connection { diff --git a/giterated-daemon/src/connection/handshake.rs b/giterated-daemon/src/connection/handshake.rs index e053a59..56344c0 100644 --- a/giterated-daemon/src/connection/handshake.rs +++ b/giterated-daemon/src/connection/handshake.rs @@ -8,7 +8,7 @@ use semver::Version; use crate::{ connection::ConnectionError, - message::{Message, MessageHandler, NetworkMessage, State, HandshakeMessage}, + message::{HandshakeMessage, Message, MessageHandler, NetworkMessage, State}, validate_version, version, }; diff --git a/giterated-daemon/src/connection/wrapper.rs b/giterated-daemon/src/connection/wrapper.rs index f8e0060..926afc7 100644 --- a/giterated-daemon/src/connection/wrapper.rs +++ b/giterated-daemon/src/connection/wrapper.rs @@ -11,7 +11,10 @@ use anyhow::Error; use futures_util::{SinkExt, StreamExt}; use giterated_models::{ messages::error::ConnectionError, - model::{authenticated::{Authenticated, AuthenticatedPayload}, instance::Instance}, + model::{ + authenticated::{Authenticated, AuthenticatedPayload}, + instance::Instance, + }, }; use rsa::RsaPublicKey; use serde::Serialize; diff --git a/giterated-daemon/src/message.rs b/giterated-daemon/src/message.rs index 987010d..6d9754a 100644 --- a/giterated-daemon/src/message.rs +++ b/giterated-daemon/src/message.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, ops::Deref}; use anyhow::Error; use futures_util::Future; use giterated_models::model::{ - authenticated::{Authenticated, AuthenticationSource, UserTokenMetadata, AuthenticatedPayload}, + authenticated::{Authenticated, AuthenticatedPayload, AuthenticationSource, UserTokenMetadata}, instance::Instance, user::User, }; @@ -110,7 +110,7 @@ impl FromMessage for AuthenticatedInstance { ) -> Result { let message: AuthenticatedPayload = serde_json::from_slice(&network_message).map_err(|e| Error::from(e))?; - + let (instance, signature) = message .source .iter() @@ -261,7 +261,7 @@ async fn public_key(instance: &Instance) -> Result { } /// Handshake-specific message type. -/// +/// /// Uses basic serde_json-based deserialization to maintain the highest /// level of compatibility across versions. pub struct HandshakeMessage(pub T); @@ -275,4 +275,4 @@ where async fn from_message(message: &NetworkMessage, _: &S) -> Result { Ok(HandshakeMessage(serde_json::from_slice(&message.0)?)) } -} \ No newline at end of file +} diff --git a/giterated-models/src/messages/authentication.rs b/giterated-models/src/messages/authentication.rs index c714771..6ee8984 100644 --- a/giterated-models/src/messages/authentication.rs +++ b/giterated-models/src/messages/authentication.rs @@ -7,7 +7,7 @@ use crate::model::authenticated::UserAuthenticationToken; /// # Authentication /// - Instance Authentication /// - **ONLY ACCEPTED WHEN SAME-INSTANCE** -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RegisterAccountRequest { pub username: String, pub email: Option, @@ -30,13 +30,13 @@ pub struct RegisterAccountResponse { /// - 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)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct AuthenticationTokenRequest { pub username: String, pub password: String, } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct AuthenticationTokenResponse { pub token: UserAuthenticationToken, } @@ -51,12 +51,12 @@ pub struct AuthenticationTokenResponse { /// # Authorization /// - Token-based /// - Validates authorization using token's authenticity -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct TokenExtensionRequest { pub token: UserAuthenticationToken, } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct TokenExtensionResponse { pub new_token: Option, } diff --git a/giterated-models/src/messages/handshake.rs b/giterated-models/src/messages/handshake.rs index e62f3ad..639d9c6 100644 --- a/giterated-models/src/messages/handshake.rs +++ b/giterated-models/src/messages/handshake.rs @@ -4,19 +4,19 @@ use serde::{Deserialize, Serialize}; use crate::model::instance::Instance; /// Sent by the initiator of a new inter-daemon connection. -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct InitiateHandshake { pub version: Version, } /// Sent in response to [`InitiateHandshake`] -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct HandshakeResponse { pub identity: Instance, pub version: Version, } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct HandshakeFinalize { pub success: bool, } diff --git a/giterated-models/src/messages/issues.rs b/giterated-models/src/messages/issues.rs index b4a9c3a..1c8f262 100644 --- a/giterated-models/src/messages/issues.rs +++ b/giterated-models/src/messages/issues.rs @@ -2,17 +2,17 @@ use serde::{Deserialize, Serialize}; use crate::model::repository::Repository; -#[derive(Clone)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct IssuesCountCommand { pub respository: Repository, } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct IssuesCountResponse { pub count: u64, } -#[derive(Clone)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct IssuesLabelsCommand { pub repository: Repository, } diff --git a/giterated-models/src/messages/repository.rs b/giterated-models/src/messages/repository.rs index 3826c84..f7833de 100644 --- a/giterated-models/src/messages/repository.rs +++ b/giterated-models/src/messages/repository.rs @@ -19,7 +19,7 @@ use crate::model::{ /// - Used to authorize action using User token requiring a correct `issued_for` and valid issuance from user's instance /// - User Authorization /// - Potential User permissions checks -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryCreateRequest { pub name: String, pub description: Option, @@ -28,7 +28,7 @@ pub struct RepositoryCreateRequest { pub owner: User, } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryCreateResponse; /// A request to inspect the tree of a repository. @@ -40,12 +40,12 @@ pub struct RepositoryCreateResponse; /// # Authorization /// - User Authorization /// - Potential User permissions checks -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryFileInspectRequest { pub path: RepositoryTreeEntry, } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub enum RepositoryFileInspectionResponse { File { commit_metadata: Commit, @@ -68,10 +68,10 @@ pub enum RepositoryFileInspectionResponse { /// # Authorization /// - User Authorization /// - Potential User permissions checks -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryIssuesCountRequest; -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryIssuesCountResponse { pub count: u64, } @@ -85,15 +85,15 @@ pub struct RepositoryIssuesCountResponse { /// # Authorization /// - User Authorization /// - Potential User permissions checks -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryIssueLabelsRequest; -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryIssueLabelsResponse { pub labels: Vec, } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct IssueLabel { pub name: String, pub color: String, @@ -108,10 +108,10 @@ pub struct IssueLabel { /// # Authorization /// - User Authorization /// - Potential User permissions checks -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryIssuesRequest; -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryIssuesResponse { pub issues: Vec, } @@ -125,7 +125,7 @@ pub struct RepositoryIssuesResponse { /// # Authorization /// - User Authorization /// - Potential User permissions checks -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryIssue { pub author: User, pub id: u64, @@ -134,7 +134,7 @@ pub struct RepositoryIssue { pub labels: Vec, } -#[derive(Clone, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct RepositoryInfoRequest { pub repository: Repository, /// Whether to fetch extra metadata like the last commit made to file or size