From 36f9dbb47a64aa0acb22b4be94b34d97e6c3c0a4 Mon Sep 17 00:00:00 2001 From: "Michael H." Date: Wed, 26 Aug 2026 12:28:25 +0200 Subject: [PATCH] chore: omit ip from usercheck decision requests --- apps/labrinth/src/routes/internal/flows.rs | 21 +++++++-------------- apps/labrinth/src/util/usercheck.rs | 16 ++++------------ 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/apps/labrinth/src/routes/internal/flows.rs b/apps/labrinth/src/routes/internal/flows.rs index cf0e0b07a3..15fb4dce0a 100644 --- a/apps/labrinth/src/routes/internal/flows.rs +++ b/apps/labrinth/src/routes/internal/flows.rs @@ -24,7 +24,6 @@ use crate::util::error::ApiContext as _; use crate::util::error::Context; use crate::util::ext::get_image_ext; use crate::util::img::upload_image_optimized; -use crate::util::ip::client_ip; use crate::util::neverbounce::{check_email, email_check_error_generic}; use crate::util::usercheck::{ DecisionAction, check_email_gate, gate_block_error, @@ -1545,7 +1544,7 @@ pub async fn create_oauth_account( }; if let Some(email) = &user.email { - ensure_email_passes_gate(&req, email) + ensure_email_passes_gate(email) .await .wrap_api_err("validating email passes the signup gate")?; } @@ -1903,11 +1902,8 @@ impl From for AccountRegisterFlow { } /// Runs the UserCheck gate, which covers both password and OAuth signups. -async fn ensure_email_passes_gate( - req: &HttpRequest, - email: &str, -) -> Result<(), ApiError> { - let action = check_email_gate(email, client_ip(req).as_deref()) +async fn ensure_email_passes_gate(email: &str) -> Result<(), ApiError> { + let action = check_email_gate(email) .await .wrap_request_err("checking email address")?; @@ -1918,11 +1914,8 @@ async fn ensure_email_passes_gate( Ok(()) } -async fn ensure_email_is_usable( - req: &HttpRequest, - email: &str, -) -> Result<(), ApiError> { - ensure_email_passes_gate(req, email).await?; +async fn ensure_email_is_usable(email: &str) -> Result<(), ApiError> { + ensure_email_passes_gate(email).await?; let result = check_email(email) .await @@ -2151,7 +2144,7 @@ pub async fn create_account_with_password( ))); } - ensure_email_is_usable(&req, &new_account.email) + ensure_email_is_usable(&new_account.email) .await .wrap_api_err("validating email is usable")?; @@ -3136,7 +3129,7 @@ pub async fn set_email( ))); } - ensure_email_is_usable(&req, &email_address.email) + ensure_email_is_usable(&email_address.email) .await .wrap_api_err("validating email is usable")?; diff --git a/apps/labrinth/src/util/usercheck.rs b/apps/labrinth/src/util/usercheck.rs index 23a3d47f32..a85d162785 100644 --- a/apps/labrinth/src/util/usercheck.rs +++ b/apps/labrinth/src/util/usercheck.rs @@ -76,8 +76,6 @@ struct ResponseMeta { #[derive(Serialize)] struct DecisionRequest<'a> { email: &'a str, - #[serde(skip_serializing_if = "Option::is_none")] - ip: Option<&'a str>, } /// Asks the configured UserCheck gate whether a signup should proceed. @@ -87,10 +85,7 @@ struct DecisionRequest<'a> { /// signup, while anything else is an error that rejects the signup. /// `Challenge` resolves to `Allow` because these flows have no step-up /// mechanism past the captcha that already ran. -pub async fn check_email_gate( - email: &str, - ip: Option<&str>, -) -> eyre::Result { +pub async fn check_email_gate(email: &str) -> eyre::Result { if ENV.USERCHECK_API_KEY.is_empty() || ENV.USERCHECK_GATE_ID.is_empty() { debug!( action = "allow", @@ -100,7 +95,7 @@ pub async fn check_email_gate( } let decision_time_start = Instant::now(); - let response = request_decision(email, ip).await; + let response = request_decision(email).await; let decision_time = decision_time_start.elapsed(); let response = match response { @@ -180,10 +175,7 @@ pub fn gate_block_error() -> eyre::Error { ) } -async fn request_decision( - email: &str, - ip: Option<&str>, -) -> reqwest::Result { +async fn request_decision(email: &str) -> reqwest::Result { HTTP_CLIENT .post(format!( "{}/v0/gates/{}/decisions", @@ -192,7 +184,7 @@ async fn request_decision( )) .bearer_auth(&ENV.USERCHECK_API_KEY) .timeout(TIMEOUT) - .json(&DecisionRequest { email, ip }) + .json(&DecisionRequest { email }) .send() .await? .error_for_status()?