Daemon authendication

Refactor DaemonMessageApp to use DaemonAuth for authentication and update related RPC method
This commit is contained in:
Noor 2025-02-11 10:33:46 +00:00
parent 606c0ad395
commit f2bc29149e
Signed by: noormohammedb
GPG Key ID: E424C39E19EFD7DF
2 changed files with 12 additions and 9 deletions

@ -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);
}

@ -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<MappedPort> for (u16, u16) {
}
}
impl From<String> for DaemonMessageApp {
fn from(value: String) -> Self {
impl From<DaemonAuth> for DaemonMessageApp {
fn from(val: DaemonAuth) -> Self {
Self {
msg: Some(daemon_message_app::Msg::Pubkey(value)),
msg: Some(daemon_message_app::Msg::Auth(val)),
}
}
}