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

View file

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

View file

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

View file

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