Push to keep up to date with api
parent: tbd commit: 1034e0a
Showing 2 changed files with 18 insertions and 1 deletion
src/main.rs
@@ -1,5 +1,5 @@ | ||
1 | 1 | use anyhow::Error; |
2 | use connection::{connection_worker, Connections, RawConnection}; | |
2 | use connection::{Connections, RawConnection}; | |
3 | 3 | use giterated_daemon::{ |
4 | 4 | authentication::AuthenticationTokenGranter, |
5 | 5 | backend::{ |
src/model/authenticated.rs
@@ -62,10 +62,26 @@ impl<T: Serialize> Authenticated<T> { | ||
62 | 62 | message, |
63 | 63 | } |
64 | 64 | } |
65 | ||
66 | pub fn new_empty(message: T) -> Self { | |
67 | Self { | |
68 | source: vec![], | |
69 | message_type: type_name::<T>().to_string(), | |
70 | message, | |
71 | } | |
72 | } | |
73 | ||
74 | pub fn append_authentication(&mut self, authentication: impl AuthenticationSourceProvider) { | |
75 | let message_payload = serde_json::to_vec(&self.message).unwrap(); | |
76 | ||
77 | self.source | |
78 | .push(authentication.authenticate(&message_payload)); | |
79 | } | |
65 | 80 | } |
66 | 81 | |
67 | 82 | mod verified {} |
68 | 83 | |
84 | #[derive(Clone, Debug)] | |
69 | 85 | pub struct UserAuthenticator { |
70 | 86 | pub user: User, |
71 | 87 | pub token: UserAuthenticationToken, |
@@ -80,6 +96,7 @@ impl AuthenticationSourceProvider for UserAuthenticator { | ||
80 | 96 | } |
81 | 97 | } |
82 | 98 | |
99 | #[derive(Clone)] | |
83 | 100 | pub struct InstanceAuthenticator<'a> { |
84 | 101 | pub instance: Instance, |
85 | 102 | pub private_key: &'a str, |