Browse Source

docs: 更新appsettings.README.md,完善配置项说明

test
hyh 3 months ago
parent
commit
414f68bbe4
  1. 70
      appsettings.README.md

70
appsettings.README.md

@ -11,8 +11,11 @@
### 数据库配置
```json
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=CellularManagement;Trusted_Connection=True;MultipleActiveResultSets=true"
"DatabaseOptions": {
"DefaultConnection": "Host=localhost;Port=5432;Database=cellularmanagement;Username=postgres;Password=your-password",
"CommandTimeout": 30,
"EnableDetailedErrors": true,
"EnableSensitiveDataLogging": true
}
}
```
@ -20,34 +23,44 @@
### JWT配置
```json
{
"JwtSettings": {
"SecretKey": "your-secret-key",
"JwtOptions": {
"SecretKey": "your-512-bit-secret-key",
"Issuer": "CellularManagement",
"Audience": "CellularManagement",
"ExpiryInMinutes": 60
"Audience": "CellularManagement.WebAPI",
"ExpiryMinutes": 15,
"RefreshTokenExpiryDays": 7,
"ClockSkewMinutes": 5,
"RequireHttpsMetadata": true,
"SaveToken": false,
"ValidateIssuer": true,
"ValidateAudience": true,
"ValidateLifetime": true,
"KeyRotationDays": 30,
"MinKeyLength": 64
}
}
```
### WebSocket配置
### 认证配置
```json
{
"WebSocketSettings": {
"Path": "/ws",
"KeepAliveInterval": 120,
"ReceiveBufferSize": 4096,
"MaxConnections": 1000,
"EnableCompression": true
"Auth": {
"MaxLoginAttempts": 5,
"LoginAttemptsWindowMinutes": 15,
"LoginAttemptsCacheKeyFormat": "LoginAttempts_{0}",
"DefaultUserRole": "User",
"AccessTokenExpirationMinutes": 60,
"RefreshTokenExpirationDays": 7
}
}
```
### 缓存配置
### WebSocket配置
```json
{
"CacheSettings": {
"SlidingExpiration": 30,
"AbsoluteExpiration": 60
"WebSocket": {
"Port": 5202,
"Path": "/ws"
}
}
```
@ -58,20 +71,28 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Microsoft.AspNetCore": "Warning"
}
}
}
```
### 其他配置
```json
{
"AllowedHosts": "*"
}
```
## 环境变量配置
以下环境变量可以在不同环境中覆盖配置文件中的设置:
- `ASPNETCORE_ENVIRONMENT` - 设置运行环境(Development/Production)
- `ConnectionStrings__DefaultConnection` - 数据库连接字符串
- `JwtSettings__SecretKey` - JWT密钥
- `WebSocketSettings__MaxConnections` - WebSocket最大连接数
- `DatabaseOptions__DefaultConnection` - 数据库连接字符串
- `JwtOptions__SecretKey` - JWT密钥
- `JwtOptions__ExpiryMinutes` - JWT过期时间(分钟)
- `Auth__MaxLoginAttempts` - 最大登录尝试次数
- `WebSocket__Port` - WebSocket端口号
## 配置优先级
1. 环境变量
@ -82,4 +103,7 @@
## 安全注意事项
1. 生产环境中不要将敏感信息(如密钥、连接字符串)直接写入配置文件
2. 使用环境变量或安全的密钥管理服务来存储敏感信息
3. 确保配置文件不会被提交到版本控制系统
3. 确保配置文件不会被提交到版本控制系统
4. 在开发环境中启用 `EnableDetailedErrors``EnableSensitiveDataLogging`,但在生产环境中应禁用
5. 确保 JWT 密钥长度至少为 64 个字符
6. 定期轮换 JWT 密钥(建议每 30 天)
Loading…
Cancel
Save