diff --git a/src/main.rs b/src/main.rs index 11a4e00..648fe67 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use anyhow::Error; -use connection::{connection_worker, Connections, RawConnection}; +use connection::{Connections, RawConnection}; use giterated_daemon::{ authentication::AuthenticationTokenGranter, backend::{ diff --git a/src/model/authenticated.rs b/src/model/authenticated.rs index 0d10197..8775949 100644 --- a/src/model/authenticated.rs +++ b/src/model/authenticated.rs @@ -62,10 +62,26 @@ impl Authenticated { message, } } + + pub fn new_empty(message: T) -> Self { + Self { + source: vec![], + message_type: type_name::().to_string(), + message, + } + } + + pub fn append_authentication(&mut self, authentication: impl AuthenticationSourceProvider) { + let message_payload = serde_json::to_vec(&self.message).unwrap(); + + self.source + .push(authentication.authenticate(&message_payload)); + } } mod verified {} +#[derive(Clone, Debug)] pub struct UserAuthenticator { pub user: User, pub token: UserAuthenticationToken, @@ -80,6 +96,7 @@ impl AuthenticationSourceProvider for UserAuthenticator { } } +#[derive(Clone)] pub struct InstanceAuthenticator<'a> { pub instance: Instance, pub private_key: &'a str,