geforkt von mirrored/vaultwarden
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.
Dieser Commit ist enthalten in:
Ursprung
881c1978eb
Commit
6e5c03cc78
1 geänderte Dateien mit 16 neuen und 5 gelöschten Zeilen
|
@ -141,8 +141,11 @@ fn hibp_breach(username: String) -> JsonResult {
|
||||||
use reqwest::{header::USER_AGENT, Client};
|
use reqwest::{header::USER_AGENT, Client};
|
||||||
|
|
||||||
if let Some(api_key) = crate::CONFIG.hibp_api_key() {
|
if let Some(api_key) = crate::CONFIG.hibp_api_key() {
|
||||||
let res = Client::new()
|
let hibp_client = Client::builder()
|
||||||
.get(&url)
|
.use_sys_proxy()
|
||||||
|
.build()?;
|
||||||
|
|
||||||
|
let res = hibp_client.get(&url)
|
||||||
.header(USER_AGENT, user_agent)
|
.header(USER_AGENT, user_agent)
|
||||||
.header("hibp-api-key", api_key)
|
.header("hibp-api-key", api_key)
|
||||||
.send()?;
|
.send()?;
|
||||||
|
@ -156,9 +159,17 @@ fn hibp_breach(username: String) -> JsonResult {
|
||||||
Ok(Json(value))
|
Ok(Json(value))
|
||||||
} else {
|
} else {
|
||||||
Ok(Json(json!([{
|
Ok(Json(json!([{
|
||||||
"title": "--- Error! ---",
|
"Name": "HaveIBeenPwned",
|
||||||
"description": "HaveIBeenPwned API key not set! Go to https://haveibeenpwned.com/API/Key",
|
"Title": "--- Error! ---",
|
||||||
"logopath": "/bwrs_static/error-x.svg"
|
"Domain": "haveibeenpwned.com",
|
||||||
|
"BreachDate": "2019-08-18T00:00:00Z",
|
||||||
|
"AddedDate": "2019-08-18T00:00:00Z",
|
||||||
|
"Description": format!("HaveIBeenPwned API key not set!<br/>Go to <a href=\"https://haveibeenpwned.com/API/Key\" target=\"_blank\" rel=\"noopener\">https://haveibeenpwned.com/API/Key</a><br/><br/>Or go to: <a href=\"https://haveibeenpwned.com/account/{account}\" target=\"_blank\" rel=\"noopener\">https://haveibeenpwned.com/account/{account}</a> for a manual check.", account=username),
|
||||||
|
"LogoPath": "/bwrs_static/error-x.svg",
|
||||||
|
"PwnCount": 0,
|
||||||
|
"DataClasses": [
|
||||||
|
"Error - No API key"
|
||||||
|
]
|
||||||
}])))
|
}])))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Laden …
In neuem Issue referenzieren