Skip to content

Commit

Permalink
Add stream permission for hpr listing skfs or euis
Browse files Browse the repository at this point in the history
Allows a sanity check from routing infrastructure to re-request
information for a specific route without requiring reloading
the entire database of routing information.
  • Loading branch information
michaeldjeffrey committed Jul 29, 2023
1 parent 61f92e7 commit 456b907
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions iot_config/src/route_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ impl RouteService {
}
}

async fn verify_request_signature_or_stream<'a, R>(
&self,
signer: &PublicKey,
request: &R,
id: OrgId<'a>,
) -> Result<(), Status>
where
R: MsgVerify,
{
if let Ok(()) = self.verify_request_signature(signer, request, id).await {
return Ok(());
}
self.verify_stream_request_signature(signer, request)
}

fn sign_response(&self, response: &[u8]) -> Result<Vec<u8>, Status> {
self.signing_key
.sign(response)
Expand Down Expand Up @@ -418,8 +433,12 @@ impl iot_config::Route for RouteService {
telemetry::count_request("route", "get-euis");

let signer = verify_public_key(&request.signer)?;
self.verify_request_signature(&signer, &request, OrgId::RouteId(&request.route_id))
.await?;
self.verify_request_signature_or_stream(
&signer,
&request,
OrgId::RouteId(&request.route_id),
)
.await?;

let pool = self.pool.clone();
let (tx, rx) = tokio::sync::mpsc::channel(20);
Expand Down Expand Up @@ -739,8 +758,12 @@ impl iot_config::Route for RouteService {
telemetry::count_request("route", "list-skfs");

let signer = verify_public_key(&request.signer)?;
self.verify_request_signature(&signer, &request, OrgId::RouteId(&request.route_id))
.await?;
self.verify_request_signature_or_stream(
&signer,
&request,
OrgId::RouteId(&request.route_id),
)
.await?;

let pool = self.pool.clone();
let (tx, rx) = tokio::sync::mpsc::channel(20);
Expand Down

0 comments on commit 456b907

Please sign in to comment.