From 6e5c03cc784b866f0b2481d91d49b36071576cb8 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Tue, 8 Oct 2019 21:39:11 +0200 Subject: [PATCH 1/2] Some modification when no HIBP API Key is set - Added an URL with the useraccount for manual check. - Added support for HTTP(S)_PROXY for hibp. --- src/api/core/mod.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index c37c6f21..edf606ee 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -141,8 +141,11 @@ fn hibp_breach(username: String) -> JsonResult { use reqwest::{header::USER_AGENT, Client}; if let Some(api_key) = crate::CONFIG.hibp_api_key() { - let res = Client::new() - .get(&url) + let hibp_client = Client::builder() + .use_sys_proxy() + .build()?; + + let res = hibp_client.get(&url) .header(USER_AGENT, user_agent) .header("hibp-api-key", api_key) .send()?; @@ -156,9 +159,17 @@ fn hibp_breach(username: String) -> JsonResult { Ok(Json(value)) } else { Ok(Json(json!([{ - "title": "--- Error! ---", - "description": "HaveIBeenPwned API key not set! Go to https://haveibeenpwned.com/API/Key", - "logopath": "/bwrs_static/error-x.svg" + "Name": "HaveIBeenPwned", + "Title": "--- Error! ---", + "Domain": "haveibeenpwned.com", + "BreachDate": "2019-08-18T00:00:00Z", + "AddedDate": "2019-08-18T00:00:00Z", + "Description": format!("HaveIBeenPwned API key not set!
Go to https://haveibeenpwned.com/API/Key

Or go to: https://haveibeenpwned.com/account/{account} for a manual check.", account=username), + "LogoPath": "/bwrs_static/error-x.svg", + "PwnCount": 0, + "DataClasses": [ + "Error - No API key" + ] }]))) } } From edc482c8ea36fdefa2913cfd54eb52af5045eb24 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Tue, 8 Oct 2019 22:29:12 +0200 Subject: [PATCH 2/2] Changed HIBP Error message. - Moved the manual link to the check to the top. - Clearified that hibp is a payed service. - Changed error logo to hibp logo. --- src/api/core/mod.rs | 8 ++++---- src/api/web.rs | 1 + src/static/images/hibp.png | Bin 0 -> 9890 bytes 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 src/static/images/hibp.png diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index edf606ee..db0d7b2b 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -160,15 +160,15 @@ fn hibp_breach(username: String) -> JsonResult { } else { Ok(Json(json!([{ "Name": "HaveIBeenPwned", - "Title": "--- Error! ---", + "Title": "Manual HIBP Check", "Domain": "haveibeenpwned.com", "BreachDate": "2019-08-18T00:00:00Z", "AddedDate": "2019-08-18T00:00:00Z", - "Description": format!("HaveIBeenPwned API key not set!
Go to https://haveibeenpwned.com/API/Key

Or go to: https://haveibeenpwned.com/account/{account} for a manual check.", account=username), - "LogoPath": "/bwrs_static/error-x.svg", + "Description": format!("Go to: https://haveibeenpwned.com/account/{account} for a manual check.

HaveIBeenPwned API key not set!
Go to https://haveibeenpwned.com/API/Key to purchase an API key from HaveIBeenPwned.

", account=username), + "LogoPath": "/bwrs_static/hibp.png", "PwnCount": 0, "DataClasses": [ - "Error - No API key" + "Error - No API key set!" ] }]))) } diff --git a/src/api/web.rs b/src/api/web.rs index d80355e1..24847b9e 100644 --- a/src/api/web.rs +++ b/src/api/web.rs @@ -69,6 +69,7 @@ fn static_files(filename: String) -> Result, Error> { "mail-github.png" => Ok(Content(ContentType::PNG, include_bytes!("../static/images/mail-github.png"))), "logo-gray.png" => Ok(Content(ContentType::PNG, include_bytes!("../static/images/logo-gray.png"))), "error-x.svg" => Ok(Content(ContentType::SVG, include_bytes!("../static/images/error-x.svg"))), + "hibp.png" => Ok(Content(ContentType::PNG, include_bytes!("../static/images/hibp.png"))), "bootstrap.css" => Ok(Content(ContentType::CSS, include_bytes!("../static/scripts/bootstrap.css"))), "bootstrap-native-v4.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/bootstrap-native-v4.js"))), diff --git a/src/static/images/hibp.png b/src/static/images/hibp.png new file mode 100644 index 0000000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