Add Redis username detection logging without URL correction
This commit is contained in:
@@ -26,12 +26,6 @@ impl AppState {
|
||||
Self::new_with_config(security_config).await
|
||||
}
|
||||
|
||||
/// Инициализация с кастомной конфигурацией безопасности и исправленным URL.
|
||||
async fn new_with_config_and_url(security_config: SecurityConfig, redis_url: String) -> Self {
|
||||
log::warn!("🔧 Creating AppState with corrected Redis URL");
|
||||
Self::create_app_state_with_redis_url(security_config, redis_url).await
|
||||
}
|
||||
|
||||
/// Инициализация с кастомной конфигурацией безопасности.
|
||||
pub async fn new_with_config(security_config: SecurityConfig) -> Self {
|
||||
log::warn!("🚀 Starting AppState initialization...");
|
||||
@@ -63,7 +57,7 @@ impl AppState {
|
||||
let username = parsed_url.username();
|
||||
let password = parsed_url.password();
|
||||
|
||||
// Определяем правильное имя пользователя
|
||||
// Определяем правильное имя пользователя для диагностики
|
||||
let effective_username = if username.is_empty() && password.is_some() {
|
||||
"redis" // Дефолтное имя пользователя для Redis
|
||||
} else {
|
||||
@@ -73,11 +67,8 @@ impl AppState {
|
||||
log::warn!(" Username: '{}' (effective: '{}')", username, effective_username);
|
||||
log::warn!(" Password: {}", if password.is_some() { "***" } else { "none" });
|
||||
|
||||
// Если нужно, исправляем URL с правильным именем пользователя
|
||||
if username.is_empty() && password.is_some() {
|
||||
let corrected_url = redis_url.replace("redis://:", &format!("redis://{}:", effective_username));
|
||||
log::warn!("🔧 Using corrected Redis URL: {}", corrected_url.replace(&corrected_url.split('@').nth(0).unwrap_or(""), "***"));
|
||||
return Self::new_with_config_and_url(security_config, corrected_url).await;
|
||||
log::warn!(" ℹ️ Redis client will use default username 'redis' for authentication");
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
@@ -86,11 +77,7 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
|
||||
Self::create_app_state_with_redis_url(security_config, redis_url).await
|
||||
}
|
||||
|
||||
/// Создает AppState с указанным Redis URL.
|
||||
async fn create_app_state_with_redis_url(security_config: SecurityConfig, redis_url: String) -> Self {
|
||||
let redis_client = match RedisClient::open(redis_url) {
|
||||
Ok(client) => {
|
||||
log::warn!("✅ Redis client created successfully");
|
||||
|
||||
Reference in New Issue
Block a user