Integrating authendication

rename register_node to register_app_node
This commit is contained in:
Noor 2025-02-10 19:56:39 +05:30
parent b22b08799b
commit f1a527e22d
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146
2 changed files with 11 additions and 5 deletions

2
Cargo.lock generated

@ -418,7 +418,7 @@ dependencies = [
[[package]] [[package]]
name = "detee-shared" name = "detee-shared"
version = "0.1.0" version = "0.1.0"
source = "git+ssh://git@gitea.detee.cloud/noormohammedb/detee-shared?branch=stable_01#fce57884937a4ec02acbf2f5b370ab879b1af657" source = "git+ssh://git@gitea.detee.cloud/noormohammedb/detee-shared?branch=stable_01#65bfa113a44251dd13e5d895014f4a773e367d2e"
dependencies = [ dependencies = [
"base64", "base64",
"prost", "prost",

@ -426,14 +426,14 @@ impl BrainAppCli for BrainAppCliMock {
#[tonic::async_trait] #[tonic::async_trait]
impl BrainAppDaemon for BrainAppDaemonMock { impl BrainAppDaemon for BrainAppDaemonMock {
type RegisterNodeStream = Pin<Box<dyn Stream<Item = Result<AppContract, Status>> + Send>>; type RegisterAppNodeStream = Pin<Box<dyn Stream<Item = Result<AppContract, Status>> + Send>>;
type BrainMessagesStream = Pin<Box<dyn Stream<Item = Result<BrainMessageApp, Status>> + Send>>; type BrainMessagesStream = Pin<Box<dyn Stream<Item = Result<BrainMessageApp, Status>> + Send>>;
async fn register_node( async fn register_app_node(
&self, &self,
req: tonic::Request<RegisterAppNodeReq>, req: tonic::Request<RegisterAppNodeReq>,
) -> Result<tonic::Response<Self::RegisterNodeStream>, Status> { ) -> Result<tonic::Response<Self::RegisterAppNodeStream>, Status> {
let req_data = req.into_inner(); let req_data = check_sig_from_req(req)?;
log::info!( log::info!(
"registering app node_key : {}, owner_key: {}", "registering app node_key : {}, owner_key: {}",
&req_data.node_pubkey, &req_data.node_pubkey,
@ -569,6 +569,12 @@ impl PubkeyGetter for AirdropReq {
} }
} }
impl PubkeyGetter for RegisterAppNodeReq {
fn get_pubkey(&self) -> Option<String> {
None
}
}
fn check_sig_from_req<T: std::fmt::Debug + PubkeyGetter>(req: Request<T>) -> Result<T, Status> { fn check_sig_from_req<T: std::fmt::Debug + PubkeyGetter>(req: Request<T>) -> Result<T, Status> {
let time = match req.metadata().get("timestamp") { let time = match req.metadata().get("timestamp") {
Some(t) => t.clone(), Some(t) => t.clone(),