From d72fb3c445486e271fae179cc3cbf1994ee7a075 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 20 Nov 2023 08:32:37 +0000 Subject: [PATCH] Include path in hash --- src/main.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9f0b6a8..a529ac3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -155,6 +155,8 @@ async fn index(req: HttpRequest) -> Result> { return Err("Invalid qhash provided".into()); } + let path = req.path().as_bytes().to_owned(); + // Store sorted key-value pairs let mut set = BTreeSet::new(); { @@ -175,12 +177,16 @@ async fn index(req: HttpRequest) -> Result> { hasher.update(&value); } + hasher.update(&path); + hasher.update(secret.as_bytes()); let hash = hasher.finalize().to_hex(); - + hash[..8].to_owned() - }).await.unwrap(); + }) + .await + .unwrap(); if hash != qhash { return Err("Invalid qhash provided".into()); @@ -306,7 +312,9 @@ async fn index(req: HttpRequest) -> Result> { } else { (resp_bytes.into(), "image/jpeg") } - }).await.unwrap(); + }) + .await + .unwrap(); response.content_type(content_type); return Ok(response.body(body)); } @@ -346,8 +354,9 @@ async fn index(req: HttpRequest) -> Result> { } else { (resp_bytes.into(), "image/jpeg") } - - }).await.unwrap(); + }) + .await + .unwrap(); response.content_type(content_type); return Ok(response.body(body)); }