From f2bc29149e32df09508519f3f88cdf880728e6dd Mon Sep 17 00:00:00 2001 From: Noor Date: Tue, 11 Feb 2025 10:33:46 +0000 Subject: [PATCH] Daemon authendication Refactor DaemonMessageApp to use DaemonAuth for authentication and update related RPC method --- proto/brain.proto | 13 ++++++++----- src/types/brain.rs | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/proto/brain.proto b/proto/brain.proto index bd8c21d..723d384 100644 --- a/proto/brain.proto +++ b/proto/brain.proto @@ -91,20 +91,23 @@ message BrainMessageApp { // resource usage } } +message DaemonAuth { + string timestamp = 1; + string pubkey = 2; + repeated string contracts = 3; + string signature = 4; +} message DaemonMessageApp { oneof Msg { - string pubkey = 1; + DaemonAuth auth = 1; NewAppRes new_app_res = 2; AppNodeResources app_node_resources = 3; } } -message Pubkey { - string pubkey = 1; -} service BrainAppDaemon { rpc RegisterAppNode (RegisterAppNodeReq) returns (stream AppContract); - rpc BrainMessages (Pubkey) returns (stream BrainMessageApp); + rpc BrainMessages (DaemonAuth) returns (stream BrainMessageApp); rpc DaemonMessages (stream DaemonMessageApp) returns (Empty); } \ No newline at end of file diff --git a/src/types/brain.rs b/src/types/brain.rs index 0e8b1a3..7a34f8b 100644 --- a/src/types/brain.rs +++ b/src/types/brain.rs @@ -1,5 +1,5 @@ use crate::pb::brain::{daemon_message_app, AppNodeResources, DaemonMessageApp, NewAppRes}; -use crate::pb::brain::{AppResource, MappedPort, NewAppReq}; +use crate::pb::brain::{AppResource, DaemonAuth, MappedPort, NewAppReq}; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] @@ -81,10 +81,10 @@ impl From for (u16, u16) { } } -impl From for DaemonMessageApp { - fn from(value: String) -> Self { +impl From for DaemonMessageApp { + fn from(val: DaemonAuth) -> Self { Self { - msg: Some(daemon_message_app::Msg::Pubkey(value)), + msg: Some(daemon_message_app::Msg::Auth(val)), } } }