Skip to content

Commit

Permalink
Include path in hash
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Nov 20, 2023
1 parent 01697eb commit d72fb3c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
return Err("Invalid qhash provided".into());
}

let path = req.path().as_bytes().to_owned();

// Store sorted key-value pairs
let mut set = BTreeSet::new();
{
Expand All @@ -175,12 +177,16 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
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());
Expand Down Expand Up @@ -306,7 +312,9 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
} else {
(resp_bytes.into(), "image/jpeg")
}
}).await.unwrap();
})
.await
.unwrap();
response.content_type(content_type);
return Ok(response.body(body));
}
Expand Down Expand Up @@ -346,8 +354,9 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
} else {
(resp_bytes.into(), "image/jpeg")
}

}).await.unwrap();
})
.await
.unwrap();
response.content_type(content_type);
return Ok(response.body(body));
}
Expand Down

0 comments on commit d72fb3c

Please sign in to comment.