diff --git a/src/Config/RedisConfig.cs b/src/Config/RedisConfig.cs
index fbe3247..a099571 100644
--- a/src/Config/RedisConfig.cs
+++ b/src/Config/RedisConfig.cs
@@ -1,8 +1,25 @@
namespace YarpGateway.Config;
+///
+/// Redis 连接配置
+/// 注意:ConnectionString 应从环境变量或密钥管理服务获取,不要硬编码凭据
+///
public class RedisConfig
{
- public string ConnectionString { get; set; } = "81.68.223.70:16379,password=sl52788542";
+ ///
+ /// Redis 连接字符串
+ /// 从环境变量 REDIS_CONNECTION_STRING 读取,或从配置文件获取
+ /// 格式: host:port,password=xxx
+ ///
+ public string ConnectionString { get; set; } = string.Empty;
+
+ ///
+ /// Redis 数据库编号
+ ///
public int Database { get; set; } = 0;
+
+ ///
+ /// 实例名称前缀
+ ///
public string InstanceName { get; set; } = "YarpGateway";
-}
+}
\ No newline at end of file
diff --git a/src/Services/RedisConnectionManager.cs b/src/Services/RedisConnectionManager.cs
index e393bc6..0be874d 100644
--- a/src/Services/RedisConnectionManager.cs
+++ b/src/Services/RedisConnectionManager.cs
@@ -41,7 +41,8 @@ public class RedisConnectionManager : IRedisConnectionManager
_logger.LogError(e.Exception, "Redis connection failed");
};
- _logger.LogInformation("Connected to Redis at {ConnectionString}", _config.ConnectionString);
+ // 脱敏连接字符串中的密码
+ _logger.LogInformation("Connected to Redis at {Host}", configuration.EndPoints.FirstOrDefault()?.ToString() ?? "unknown");
return connection;
});
}
diff --git a/src/appsettings.Development.json b/src/appsettings.Development.json
index 0c208ae..d53081c 100644
--- a/src/appsettings.Development.json
+++ b/src/appsettings.Development.json
@@ -1,8 +1,34 @@
{
"Logging": {
"LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
+ "Default": "Debug",
+ "Microsoft.AspNetCore": "Information",
+ "Yarp.ReverseProxy": "Debug"
}
+ },
+ "ConnectionStrings": {
+ "DefaultConnection": ""
+ },
+ "Jwt": {
+ "Authority": "https://your-auth-server.com",
+ "Audience": "fengling-gateway",
+ "ValidateIssuer": true,
+ "ValidateAudience": true
+ },
+ "Redis": {
+ "ConnectionString": "",
+ "Database": 0,
+ "InstanceName": "YarpGateway"
+ },
+ "Cors": {
+ "AllowedOrigins": [
+ "http://localhost:5173",
+ "http://127.0.0.1:5173",
+ "http://localhost:5174"
+ ],
+ "AllowAnyOrigin": false
+ },
+ "ServiceDiscovery": {
+ "UseInClusterConfig": false
}
-}
+}
\ No newline at end of file
diff --git a/src/appsettings.json b/src/appsettings.json
index 67b5613..c06a863 100644
--- a/src/appsettings.json
+++ b/src/appsettings.json
@@ -16,16 +16,16 @@
"AllowAnyOrigin": false
},
"ConnectionStrings": {
- "DefaultConnection": "Host=81.68.223.70;Port=15432;Database=fengling_gateway;Username=movingsam;Password=sl52788542"
+ "DefaultConnection": ""
},
"Jwt": {
- "Authority": "https://your-auth-server.com",
+ "Authority": "",
"Audience": "fengling-gateway",
"ValidateIssuer": true,
"ValidateAudience": true
},
"Redis": {
- "ConnectionString": "81.68.223.70:6379",
+ "ConnectionString": "",
"Database": 0,
"InstanceName": "YarpGateway"
},
@@ -60,5 +60,8 @@
"Url": "http://0.0.0.0:8080"
}
}
+ },
+ "ServiceDiscovery": {
+ "UseInClusterConfig": true
}
-}
+}
\ No newline at end of file