Skip to content

Commit

Permalink
Limit HIBP to authed users
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-garcia committed Nov 10, 2024
1 parent 20d9e88 commit 38aad4f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/api/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ async fn put_eq_domains(data: Json<EquivDomainData>, headers: Headers, conn: DbC
}

#[get("/hibp/breach?<username>")]
async fn hibp_breach(username: &str) -> JsonResult {
let username: String = url::form_urlencoded::byte_serialize(username.as_bytes()).collect();
let url = format!(
"https://haveibeenpwned.com/api/v3/breachedaccount/{username}?truncateResponse=false&includeUnverified=false"
);

async fn hibp_breach(username: &str, _headers: Headers) -> JsonResult {
if let Some(api_key) = crate::CONFIG.hibp_api_key() {
let username: String = url::form_urlencoded::byte_serialize(username.as_bytes()).collect();
let url = format!(
"https://haveibeenpwned.com/api/v3/breachedaccount/{username}?truncateResponse=false&includeUnverified=false"
);

let res = make_http_request(Method::GET, &url)?.header("hibp-api-key", api_key).send().await?;

// If we get a 404, return a 404, it means no breached accounts
Expand Down

0 comments on commit 38aad4f

Please sign in to comment.