Skip to content

Commit

Permalink
Merge pull request #583 from helium/mj/stream-request-permission-for-…
Browse files Browse the repository at this point in the history
…euis-and-skfs

Add stream permission for hpr listing skfs or euis
  • Loading branch information
jeffgrunewald authored Aug 1, 2023
2 parents 46b9c71 + c76cb18 commit 021efe8
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 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 @@ -575,8 +594,12 @@ impl iot_config::Route for RouteService {
telemetry::count_request("route", "get-devaddr-ranges");

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 (tx, rx) = tokio::sync::mpsc::channel(20);
let pool = self.pool.clone();
Expand Down Expand Up @@ -739,8 +762,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 021efe8

Please sign in to comment.