From 0a4a6d783237af53a3fc4fa4892d891a2357b547 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 23 Oct 2023 15:47:19 -0700 Subject: [PATCH] streaming responses require premium instead of debug responses --- web3_proxy/src/app/mod.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/web3_proxy/src/app/mod.rs b/web3_proxy/src/app/mod.rs index b7e3814a..f236f612 100644 --- a/web3_proxy/src/app/mod.rs +++ b/web3_proxy/src/app/mod.rs @@ -1289,7 +1289,16 @@ impl App { } let last_response = if let Some(last_success) = last_success { - Ok(last_success) + if matches!(last_success, SingleResponse::Stream(..)) + && !(self.config.free_subscriptions + || web3_request.authorization.active_premium().await) + { + Err(Web3ProxyError::AccessDenied( + "streaming responses require an active premium account".into(), + )) + } else { + Ok(last_success) + } } else { Err(last_error.unwrap_or(anyhow::anyhow!("no success or error").into())) }; @@ -1633,16 +1642,6 @@ impl App { method )).into()); } - if method.starts_with("debug_") { - // make sure its premium - if !(self.config.free_subscriptions - || web3_request.authorization.active_premium().await) - { - return Err(Web3ProxyError::AccessDenied( - "debug methods require an active premium account".into(), - )); - } - } if web3_request.cache_mode.is_some() { // don't cache anything larger than 16 MiB