From 767065d232fb9d819bdb5d1358ba09cf9363c47b Mon Sep 17 00:00:00 2001 From: jeffgrunewald Date: Sun, 13 Aug 2023 14:12:36 -0400 Subject: [PATCH 1/2] bubble up route uuid parse errors to user --- iot_config/src/route_service.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iot_config/src/route_service.rs b/iot_config/src/route_service.rs index ada31fa1a..fe7d81dba 100644 --- a/iot_config/src/route_service.rs +++ b/iot_config/src/route_service.rs @@ -93,7 +93,10 @@ impl RouteService { OrgId::Oui(oui) => org::get_org_pubkeys(oui, &self.pool).await, OrgId::RouteId(route_id) => org::get_org_pubkeys_by_route(route_id, &self.pool).await, } - .map_err(|_| Status::internal("auth verification error"))?; + .map_err(|err| match err { + OrgStoreError::RouteIdParse(id_err) => Status::invalid_argument(id_err.to_string()), + _ => Status::internal("auth verification error"), + })?; if org_keys.as_slice().contains(signer) && request.verify(signer).is_ok() { tracing::debug!( From 1f4656a38288da2084f95e164a70cb3f30fec5fa Mon Sep 17 00:00:00 2001 From: jeffgrunewald Date: Tue, 15 Aug 2023 18:52:18 -0400 Subject: [PATCH 2/2] flip auth method order to return underlying result --- iot_config/src/route_service.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/iot_config/src/route_service.rs b/iot_config/src/route_service.rs index fe7d81dba..a3cd2b188 100644 --- a/iot_config/src/route_service.rs +++ b/iot_config/src/route_service.rs @@ -134,10 +134,13 @@ impl RouteService { where R: MsgVerify, { - if let Ok(()) = self.verify_request_signature(signer, request, id).await { + if self + .verify_stream_request_signature(signer, request) + .is_ok() + { return Ok(()); } - self.verify_stream_request_signature(signer, request) + self.verify_request_signature(signer, request, id).await } fn sign_response(&self, response: &[u8]) -> Result, Status> {