chore: initial commit for phase04

This commit is contained in:
hibna
2026-02-21 15:50:35 +03:00
parent d0c20581b6
commit 218452706c
15 changed files with 4310 additions and 8 deletions
+15
View File
@@ -0,0 +1,15 @@
use tonic::{Request, Status};
/// Validate the daemon token from the gRPC request metadata.
pub fn check_auth(req: &Request<()>, expected_token: &str) -> Result<(), Status> {
let token = req
.metadata()
.get("authorization")
.and_then(|v| v.to_str().ok())
.and_then(|v| v.strip_prefix("Bearer "));
match token {
Some(t) if t == expected_token => Ok(()),
_ => Err(Status::unauthenticated("Invalid or missing daemon token")),
}
}