Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(user): use mget to check in blocklist (#3945)
Apoorv Dixit8154a611efcf
diff --git a/crates/router/src/services/authentication/blacklist.rs b/crates/router/src/services/authentication/blacklist.rsindex 2ee8302be6..b5cdcaf084 100644--- a/crates/router/src/services/authentication/blacklist.rs+++ b/crates/router/src/services/authentication/blacklist.rs@@ -80,19 +80,25 @@ pub async fn check_user_in_blacklist<A: AppStateInfo>(.map(|timestamp| timestamp.map_or(false, |timestamp| timestamp > token_issued_at))}-pub async fn check_role_in_blacklist<A: AppStateInfo>(+pub async fn check_user_and_role_in_blacklist<A: AppStateInfo>(state: &A,+ user_id: &str,role_id: &str,token_expiry: u64,) -> RouterResult<bool> {- let token = format!("{}{}", ROLE_BLACKLIST_PREFIX, role_id);+ let user_token = format!("{}{}", USER_BLACKLIST_PREFIX, user_id);+ let role_token = format!("{}{}", ROLE_BLACKLIST_PREFIX, role_id);let token_issued_at = expiry_to_i64(token_expiry - JWT_TOKEN_TIME_IN_SECS)?;let redis_conn = get_redis_connection(state)?;- redis_conn- .get_key::<Option<i64>>(token.as_str())++ Ok(redis_conn+ .get_multiple_keys::<Vec<&str>, i64>(vec![user_token.as_str(), role_token.as_str()]).await- .change_context(ApiErrorResponse::InternalServerError)- .map(|timestamp| timestamp.map_or(false, |timestamp| timestamp > token_issued_at))+ .change_context(ApiErrorResponse::InternalServerError)?+ .into_iter()+ .max()+ .flatten()+ .map_or(false, |timestamp| timestamp > token_issued_at))}#[cfg(feature = "email")]@@ -150,10 +156,7 @@ impl BlackList for AuthToken {whereA: AppStateInfo + Sync,{- Ok(- check_user_in_blacklist(state, &self.user_id, self.exp).await?- || check_role_in_blacklist(state, &self.role_id, self.exp).await?,- )+ check_user_and_role_in_blacklist(state, &self.user_id, &self.role_id, self.exp).await}}