fix hipb typo

This commit is contained in:
Valentin Tolmer 2023-04-13 09:32:53 +02:00
parent 278fb1630d
commit 8c052c091e
4 changed files with 16 additions and 16 deletions

View File

@ -501,10 +501,10 @@ async fn get_password_hash_list(
.header("hibp-api-key", api_key.unsecure()) .header("hibp-api-key", api_key.unsecure())
.send() .send()
.await .await
.context("Could not get response from HIPB")? .context("Could not get response from HIBP")?
.text() .text()
.await?; .await?;
parse_hash_list(&resp).context("Invalid HIPB response") parse_hash_list(&resp).context("Invalid HIBP response")
} }
async fn check_password_pwned<Backend>( async fn check_password_pwned<Backend>(
@ -536,8 +536,8 @@ where
"No token or invalid token".to_string(), "No token or invalid token".to_string(),
)); ));
} }
if data.hipb_api_key.unsecure().is_empty() { if data.hibp_api_key.unsecure().is_empty() {
return Err(TcpError::NotImplemented("No HIPB API key".to_string())); return Err(TcpError::NotImplemented("No HIBP API key".to_string()));
} }
let hash = request let hash = request
.match_info() .match_info()
@ -549,7 +549,7 @@ where
hash hash
))); )));
} }
get_password_hash_list(hash, &data.hipb_api_key) get_password_hash_list(hash, &data.hibp_api_key)
.await .await
.map(|hashes| HttpResponse::Ok().json(hashes)) .map(|hashes| HttpResponse::Ok().json(hashes))
.map_err(|e| TcpError::InternalServerError(e.to_string())) .map_err(|e| TcpError::InternalServerError(e.to_string()))

View File

@ -82,8 +82,8 @@ pub struct RunOpts {
pub database_url: Option<String>, pub database_url: Option<String>,
/// HaveIBeenPwned API key, to check passwords against leaks. /// HaveIBeenPwned API key, to check passwords against leaks.
#[clap(long, env = "LLDAP_HIPB_API_KEY")] #[clap(long, env = "LLDAP_HIBP_API_KEY")]
pub hipb_api_key: Option<String>, pub hibp_api_key: Option<String>,
#[clap(flatten)] #[clap(flatten)]
pub smtp_opts: SmtpOpts, pub smtp_opts: SmtpOpts,

View File

@ -99,7 +99,7 @@ pub struct Configuration {
#[builder(default = r#"String::from("http://localhost")"#)] #[builder(default = r#"String::from("http://localhost")"#)]
pub http_url: String, pub http_url: String,
#[builder(default = r#"SecUtf8::from("")"#)] #[builder(default = r#"SecUtf8::from("")"#)]
pub hipb_api_key: SecUtf8, pub hibp_api_key: SecUtf8,
#[serde(skip)] #[serde(skip)]
#[builder(field(private), default = "None")] #[builder(field(private), default = "None")]
server_setup: Option<ServerSetup>, server_setup: Option<ServerSetup>,
@ -216,8 +216,8 @@ impl ConfigOverrider for RunOpts {
config.database_url = database_url.to_string(); config.database_url = database_url.to_string();
} }
if let Some(api_key) = self.hipb_api_key.as_ref() { if let Some(api_key) = self.hibp_api_key.as_ref() {
config.hipb_api_key = SecUtf8::from(api_key.clone()); config.hibp_api_key = SecUtf8::from(api_key.clone());
} }
self.smtp_opts.override_config(config); self.smtp_opts.override_config(config);
self.ldaps_opts.override_config(config); self.ldaps_opts.override_config(config);

View File

@ -89,7 +89,7 @@ fn http_config<Backend>(
jwt_blacklist: HashSet<u64>, jwt_blacklist: HashSet<u64>,
server_url: String, server_url: String,
mail_options: MailOptions, mail_options: MailOptions,
hipb_api_key: SecUtf8, hibp_api_key: SecUtf8,
) where ) where
Backend: TcpBackendHandler + BackendHandler + LoginHandler + OpaqueHandler + Clone + 'static, Backend: TcpBackendHandler + BackendHandler + LoginHandler + OpaqueHandler + Clone + 'static,
{ {
@ -100,7 +100,7 @@ fn http_config<Backend>(
jwt_blacklist: RwLock::new(jwt_blacklist), jwt_blacklist: RwLock::new(jwt_blacklist),
server_url, server_url,
mail_options, mail_options,
hipb_api_key, hibp_api_key,
})) }))
.route( .route(
"/health", "/health",
@ -136,7 +136,7 @@ pub(crate) struct AppState<Backend> {
pub jwt_blacklist: RwLock<HashSet<u64>>, pub jwt_blacklist: RwLock<HashSet<u64>>,
pub server_url: String, pub server_url: String,
pub mail_options: MailOptions, pub mail_options: MailOptions,
pub hipb_api_key: SecUtf8, pub hibp_api_key: SecUtf8,
} }
impl<Backend: BackendHandler> AppState<Backend> { impl<Backend: BackendHandler> AppState<Backend> {
@ -177,7 +177,7 @@ where
let mail_options = config.smtp_options.clone(); let mail_options = config.smtp_options.clone();
let verbose = config.verbose; let verbose = config.verbose;
info!("Starting the API/web server on port {}", config.http_port); info!("Starting the API/web server on port {}", config.http_port);
let hipb_api_key = config.hipb_api_key.clone(); let hibp_api_key = config.hibp_api_key.clone();
server_builder server_builder
.bind( .bind(
"http", "http",
@ -188,7 +188,7 @@ where
let jwt_blacklist = jwt_blacklist.clone(); let jwt_blacklist = jwt_blacklist.clone();
let server_url = server_url.clone(); let server_url = server_url.clone();
let mail_options = mail_options.clone(); let mail_options = mail_options.clone();
let hipb_api_key = hipb_api_key.clone(); let hibp_api_key = hibp_api_key.clone();
HttpServiceBuilder::default() HttpServiceBuilder::default()
.finish(map_config( .finish(map_config(
App::new() App::new()
@ -204,7 +204,7 @@ where
jwt_blacklist, jwt_blacklist,
server_url, server_url,
mail_options, mail_options,
hipb_api_key, hibp_api_key,
) )
}), }),
|_| AppConfig::default(), |_| AppConfig::default(),