From 7d1c908b1b7d57ceba201d83cb7ccf4e5d924b53 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Thu, 29 May 2025 15:55:17 +0100 Subject: [PATCH] box authenticate task --- proxy/src/proxy/mod.rs | 50 +++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/proxy/src/proxy/mod.rs b/proxy/src/proxy/mod.rs index 235a8ed099..8497a53cba 100644 --- a/proxy/src/proxy/mod.rs +++ b/proxy/src/proxy/mod.rs @@ -354,30 +354,36 @@ pub(crate) async fn handle_client( return Ok(None); }; - let user = user_info.user.clone(); - let compute_creds = match cplane - .authenticate( - ctx, - &mut stream, - user_info, - mode.allow_cleartext(), - &config.authentication_config, - endpoint_rate_limiter, - ) - .await - { - Ok(auth_result) => auth_result, - Err(e) => { - let db = params.get("database"); - let app = params.get("application_name"); - let params_span = tracing::info_span!("", ?user, ?db, ?app); + let auth_result: Result<_, ClientRequestError> = async { + let user = user_info.user.clone(); - return stream - .throw_error(e, Some(ctx)) - .instrument(params_span) - .await?; + match cplane + .authenticate( + ctx, + &mut stream, + user_info, + mode.allow_cleartext(), + &config.authentication_config, + endpoint_rate_limiter, + ) + .await + { + Ok(auth_result) => Ok(auth_result), + Err(e) => { + let db = params.get("database"); + let app = params.get("application_name"); + let params_span = tracing::info_span!("", ?user, ?db, ?app); + stream + .throw_error(e, Some(ctx)) + .instrument(params_span) + .await? + } } - }; + } + .boxed() + .await; + + let compute_creds = auth_result?; let compute_user_info = compute_creds.info.clone(); let params_compat = compute_user_info