config: improve Redis configuration and credentials management
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
eec65c1e05
commit
d7007d0d7f
@ -1,8 +1,25 @@
|
||||
namespace YarpGateway.Config;
|
||||
|
||||
/// <summary>
|
||||
/// Redis 连接配置
|
||||
/// 注意:ConnectionString 应从环境变量或密钥管理服务获取,不要硬编码凭据
|
||||
/// </summary>
|
||||
public class RedisConfig
|
||||
{
|
||||
public string ConnectionString { get; set; } = "81.68.223.70:16379,password=sl52788542";
|
||||
/// <summary>
|
||||
/// Redis 连接字符串
|
||||
/// 从环境变量 REDIS_CONNECTION_STRING 读取,或从配置文件获取
|
||||
/// 格式: host:port,password=xxx
|
||||
/// </summary>
|
||||
public string ConnectionString { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Redis 数据库编号
|
||||
/// </summary>
|
||||
public int Database { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 实例名称前缀
|
||||
/// </summary>
|
||||
public string InstanceName { get; set; } = "YarpGateway";
|
||||
}
|
||||
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user