
Configuration
Namespace:
ZhonTai.Admin.Core.Configs
The main configuration file is appconfig.json, mapped to the AppConfig class. Additional configurations exist for database, JWT, email, OSS, cache, rate limiting, etc.
AppConfig Main Configuration
Config file:
Configs/appconfig.json
Settings
| Setting | Type | Description |
|---|---|---|
AppType | string | Application type: Controllers / ControllersWithViews / MVC |
Urls | string[] | Listen URL list, e.g. [ "http://*:18010" ] |
CorUrls | string[] | CORS URL list |
AssemblyNames | string[] | Assembly names to scan |
EnumListAssemblyNames | string[] | Enum list assembly names |
Tenant | bool | Enable multi-tenancy |
DistributeKey | string | Distributed transaction unique identifier, empty means no distributed transaction tables |
DefaultPassword | string | Default password |
Lang | object | Language configuration |
Lang.EnableJson | bool | Enable language configuration |
Lang.DefaultLang | string | Default language, e.g. zh-CN |
Lang.Langs | string[] | Supported language list |
Lang.RequestCultureProviders | string[] | Language request providers: QueryString, Cookie, AcceptLanguageHeader |
Validate | object | Validation configuration |
Validate.Login | bool | Enable login validation |
Validate.Permission | bool | Enable permission validation |
Validate.DataPermission | bool | Enable data permissions |
Validate.ApiDataPermission | bool | Enable API-level data permissions |
Aop | object | AOP configuration |
Aop.Transaction | bool | Enable declarative transactions |
Swagger | object | Swagger configuration |
Swagger.Enable | bool | Enable Swagger |
Swagger.EnableEnumSchemaFilter | bool | Enable enum schema filter |
Swagger.EnableOrderTagsDocumentFilter | bool | Enable API ordering document filter |
Swagger.EnableJsonStringEnumConverter | bool | Enable enum property names |
Swagger.EnableSchemaIdNamespace | bool | Enable SchemaId namespace |
Swagger.AssemblyNameList | string[] | Assembly list for SchemaId namespace |
Swagger.RoutePrefix | string | Route prefix, e.g. doc/module/swagger for microservice docs |
Swagger.Url | string | Swagger URL |
Swagger.Projects | object[] | Swagger project group list |
ApiUI | object | New API UI configuration |
ApiUI.Enable | bool | Enable API UI |
ApiUI.RoutePrefix | string | Route prefix |
ApiUI.Footer | object | Footer configuration |
MiniProfiler | bool | Enable MiniProfiler performance analyzer |
Log | object | Log configuration |
Log.Operation | bool | Enable operation logging |
Log.Method | string | Log recording method: Grpc / Cap |
RateLimit | bool | Enable rate limiting |
VarifyCode | object | Captcha configuration |
VarifyCode.Enable | bool | Enable captcha |
VarifyCode.Fonts | string[] | Font list |
DynamicApi | object | Dynamic API configuration |
DynamicApi.FormatResult | bool | Enable result formatting |
PasswordHasher | bool | Implement standard identity password hashing |
Kestrel | object | Kestrel server configuration |
Kestrel.KeepAliveTimeout | int | HTTP keep-alive timeout (seconds) |
Kestrel.RequestHeadersTimeout | int | Request headers timeout (seconds) |
Kestrel.MaxRequestBodySize | long | Max request body size (bytes), null for unlimited |
HealthChecks | object | Health check configuration |
HealthChecks.Enable | bool | Enable health checks |
HealthChecks.Path | string | Health check path |
PreflightMaxAge | int | CORS preflight max age (seconds), default 1800 |
TaskSchedulerUI | object | Task scheduler UI configuration |
TaskSchedulerUI.Enable | bool | Enable task scheduler UI |
TaskSchedulerUI.Path | string | Access path |
IdGenerator | object | ID generator configuration |
IdGenerator.DataCenterId | int | Data center ID |
IdGenerator.WorkerId | int | Worker ID, must be globally unique |
IdGenerator.WorkerIdBitLength | int | Worker ID bit length, default 6 |
IdGenerator.SeqBitLength | int | Sequence bit length, default 6 |
IdGenerator.CachePrefix | string | Cache prefix |
IP2Region | object | IP address geolocation configuration |
IP2Region.Enable | bool | Enable IP geolocation |
IP2Region.DbPath | string | Absolute database path, defaults to ip2region.xdb in web root |
Configuration Example
json
{
"AppConfig": {
"appType": "Controllers",
"urls": [ "http://*:18010" ],
"corUrls": [],
"assemblyNames": [ "ZhonTai.Admin.Core", "ZhonTai.Module.Admin" ],
"EnumListAssemblyNames": [],
"tenant": true,
"distributeKey": "",
"validate": {
"login": true,
"permission": true,
"dataPermission": true,
"apiDataPermission": true
},
"swagger": {
"enable": true,
"enableEnumSchemaFilter": true,
"enableOrderTagsDocumentFilter": true,
"enableJsonStringEnumConverter": false,
"enableSchemaIdNamespace": false,
"assemblyNameList": [],
"routePrefix": "doc/sys/swagger",
"url": "http://localhost:18010",
"projects": [
{
"name": "ZhonTai Admin",
"code": "admin",
"version": "v10.0.1",
"description": "Permission Management"
}
]
},
"apiUI": {
"enable": true,
"routePrefix": "doc/sys",
"footer": {
"enable": false,
"content": ""
}
},
"miniProfiler": false,
"aop": {
"transaction": true
},
"log": {
"operation": true,
"method": "Grpc"
},
"rateLimit": false,
"varifyCode": {
"enable": true,
"fonts": [ "Times New Roman", "Verdana", "Arial", "Gungsuh", "Impact" ]
},
"defaultPassword": "123asd",
"dynamicApi": {
"formatResult": true
},
"passwordHasher": false,
"Kestrel": {
"KeepAliveTimeout": 600,
"RequestHeadersTimeout": 600,
"maxRequestBodySize": 104857600
},
"healthChecks": {
"enable": true,
"path": "/health"
},
"PreflightMaxAge": 1800,
"TaskSchedulerUI": {
"enable": true,
"path": "/task"
},
"IdGenerator": {
"DataCenterId": 0,
"WorkerId": 1,
"WorkerIdBitLength": 6,
"SeqBitLength": 6,
"CachePrefix": "zhontai:workerid"
},
"IP2Region": {
"Enable": true,
"DbPath": ""
},
"Lang": {
"EnableJson": true,
"DefaultLang": "zh-CN",
"Langs": [ "zh-CN", "en" ],
"RequestCultureProviders": []
}
}
}DbConfig Database Configuration
Config file:
Configs/dbconfig.json
Settings
| Setting | Type | Description |
|---|---|---|
Key | string | Database registration key (e.g. AdminDb, LogDb) |
Type | string | Database type: MySql / SqlServer / PostgreSQL / Sqlite / Oracle / TiDB etc. |
ConnectionString | string | Connection string |
AssemblyNames | string[] | Assembly names to auto-load entities, empty for custom ConfigureFreeSql |
IncludeEntityDbs | string[] | Include entity database list, empty means all |
ExcludeEntityDbs | string[] | Exclude entity database list |
MonitorCommand | bool | Monitor all commands |
Curd | bool | Monitor CRUD operations |
SyncStructureSql | bool | Monitor sync structure SQL |
SyncDataCurd | bool | Monitor sync data CRUD |
CreateDb | bool | Create database |
CreateDbConnectionString | string | Create database connection string |
CreateDbSql | string | Create database SQL script |
SyncStructure | bool | Auto-sync table structure |
SyncStructureEntityBatchSize | int | Sync structure entity batch size |
SyncDataBatchSize | int | Sync data batch size, default 500, too large may cause OOM |
SyncData | bool | Auto-sync seed data |
SyncUpdateData | bool | Sync update data, use with caution in production |
SyncDataPath | string | Sync data path |
SyncDataIncludeTables | string[] | Include tables for sync |
SyncDataExcludeTables | string[] | Exclude tables from sync |
SyncDataUser | object | Sync data user |
GenerateData | bool | Generate seed data package, remember to disable after use |
ProviderType | string | Custom provider assembly |
SlaveList | object[] | Read-write separation slave list |
IdleTime | int | Idle time (minutes), 0 means no auto-recycle |
ForceUpdate | bool | Force update EntityUpdate data on insert |
Dbs | object[] | Multiple database configs |
Configuration Example
json
{
"DbConfig": {
"key": "sysdb",
"assemblyNames": [ "ZhonTai.Admin" ],
"type": "MySql",
"connectionString": "Server=localhost;Port=3306;Database=sysdb;Uid=root;Pwd=pwd;Charset=utf8mb4;Min pool size=1;Allow User Variables=True",
"createDb": true,
"createDbConnectionString": "Server=localhost;Port=3306;Database=mysql;Uid=root;Pwd=pwd;Charset=utf8mb4;Min pool size=1;Allow User Variables=True",
"createDbSql": "CREATE DATABASE `sysdb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'",
"syncStructure": true,
"syncStructureEntityBatchSize": 1,
"syncDataBatchSize": 500,
"syncData": true,
"syncUpdateData": false,
"SyncDataPath": "InitData/App",
"syncDataIncludeTables": [],
"syncDataExcludeTables": [],
"syncDataUser": {
"id": 161223411986501,
"userName": "admin",
"name": "Admin",
"tenantId": 161223412138053
},
"generateData": false,
"idleTime": 1440,
"forceUpdate": false,
"dbs": [
{
"key": "admindb",
"assemblyNames": [ "ZhonTai.Admin" ],
"type": "MySql",
"connectionString": "Server=localhost;Port=3306;Database=admindb;Uid=root;Pwd=pwd;Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
},
{
"key": "logdb",
"assemblyNames": [ "ZhonTai.Admin" ],
"includeEntityDbs": [ "Log" ],
"type": "MySql",
"connectionString": "Server=localhost;Port=3306;Database=logdb;Uid=root;Pwd=pwd;Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
}
]
}
}JwtConfig JWT Configuration
Config file:
Configs/jwtconfig.json
Settings
| Setting | Type | Description |
|---|---|---|
Issuer | string | Token issuer |
Audience | string | Token audience |
SecurityKey | string | Secret key (custom) |
Expires | int | Access Token expiry (minutes), 120 = 2 hours |
RefreshExpires | int | Refresh Token expiry (minutes), 1440 = 1 day |
Configuration Example
json
{
"JwtConfig": {
"issuer": "admin.core",
"audience": "admin.core",
"securityKey": "73A74C69E2CF4522A7C69375CA0354D8",
"expires": 120,
"refreshExpires": 1440
}
}EmailConfig Email Configuration
Config file:
Configs/appsettings.json
Settings
| Setting | Type | Description |
|---|---|---|
Host | string | SMTP host, e.g. smtp.qq.com |
Port | int | Port number, e.g. 465, 587, 25 |
UseSsl | bool | Use SSL |
UserName | string | Email account |
Password | string | Email password |
FromEmail | object | Sender information |
FromEmail.Name | string | Sender name |
FromEmail.Address | string | Sender address |
ToEmail | object | Recipient information |
ToEmail.Name | string | Recipient name |
ToEmail.Address | string | Recipient address |
Configuration Example
json
{
"Email": {
"Host": "smtp.qq.com",
"Port": 465,
"UseSsl": true,
"UserName": "",
"Password": "",
"FromEmail": {
"Name": "",
"Address": ""
},
"ToEmail": {
"Name": "",
"Address": ""
}
}
}OSSConfig OSS File Upload Configuration
Config file:
Configs/ossconfig.json
Settings
| Setting | Type | Description |
|---|---|---|
LocalUploadConfig | object | Local upload configuration |
LocalUploadConfig.Directory | string | Upload directory |
LocalUploadConfig.DateTimeDirectory | string | Date directory format, e.g. yyyy/MM/dd |
LocalUploadConfig.Md5 | bool | Enable MD5 verification |
LocalUploadConfig.MaxSize | long | Max file size (bytes) |
LocalUploadConfig.IncludeExtension | string[] | Included file extension list |
LocalUploadConfig.ExcludeExtension | string[] | Excluded file extension list, e.g. [ ".exe", ".dll", ".jar" ] |
Provider | string | Default storage provider |
OSSConfigs | object[] | OSS configuration list |
Supported Providers: Minio, Aliyun, QCloud (Tencent Cloud), Qiniu, HuaweiCloud.
Each OSS configuration:
| Setting | Type | Description |
|---|---|---|
Provider | string | Provider type |
Endpoint | string | Endpoint URL |
Region | string | Region |
AccessKey | string | Access key |
SecretKey | string | Secret key |
IsEnableHttps | bool | Enable HTTPS |
IsEnableCache | bool | Enable cache |
BucketName | string | Bucket name |
Url | string | File external URL |
Md5 | bool | Enable MD5 verification |
Enable | bool | Enable this provider |
Configuration Example
json
{
"OssConfig": {
"LocalUploadConfig": {
"Directory": "upload",
"DateTimeDirectory": "yyyy/MM/dd",
"Md5": false,
"MaxSize": 104857600,
"IncludeExtension": [],
"ExcludeExtension": [ ".exe", ".dll", ".jar" ]
},
"Provider": "Minio",
"OSSConfigs": [
{
"Provider": "Minio",
"Endpoint": "127.0.0.1:9006",
"Region": "",
"AccessKey": "minio",
"SecretKey": "minio",
"IsEnableHttps": false,
"IsEnableCache": true,
"BucketName": "admin",
"Url": "",
"Md5": false,
"Enable": false
}
]
}
}RpcConfig RPC Configuration
Config file:
RpcConfigsection inConfigs/appsettings.json
Settings
| Setting | Type | Description |
|---|---|---|
Http | object | HTTP remote configuration |
Http.Enable | bool | Enable HTTP remote calls, default true |
Http.AssemblyNames | string[] | Client assembly name list, auto-includes ZhonTai.Admin.Contracts if not specified |
Grpc | object | gRPC remote configuration |
Grpc.Enable | bool | Enable gRPC remote calls, default true |
Grpc.AssemblyNames | string[] | Client assembly name list, auto-includes ZhonTai.Admin.Core if not specified |
Grpc.ServerAssemblyNames | string[] | Server assembly name list |
Endpoints | object[] | Remote endpoint list |
Endpoints[].Name | string | Module name, e.g. admin |
Endpoints[].HttpUrl | string | HTTP URL, e.g. http://localhost:18010 |
Endpoints[].GrpcUrl | string | gRPC URL, e.g. http://localhost:18011 |
Configuration Example
json
{
"RpcConfig": {
"Http": {
"Enable": true,
"AssemblyNames": [ "ZhonTai.Admin.Contracts" ]
},
"Grpc": {
"Enable": true,
"AssemblyNames": [ "ZhonTai.Admin.Core" ],
"ServerAssemblyNames": [ "ZhonTai.Admin" ]
},
"Endpoints": [
{
"Name": "admin",
"HttpUrl": "http://localhost:18010",
"GrpcUrl": "http://localhost:18011"
}
]
}
}ImConfig IM Configuration
Config file:
ImConfigsection inConfigs/appsettings.json
Settings
| Setting | Type | Description |
|---|---|---|
Enable | bool | Enable instant messaging, default false |
Servers | string[] | IM server cluster address list, e.g. [ "127.0.0.1:17010" ] |
Server | string | WebSocket business endpoint, e.g. ws://127.0.0.1:17010 |
RedisConnectionString | string | Redis connection string, e.g. 127.0.0.1:6379,password=,defaultDatabase=6 |
Configuration Example
json
{
"ImConfig": {
"Enable": false,
"Servers": [ "127.0.0.1:17010" ],
"Server": "ws://127.0.0.1:17010",
"RedisConnectionString": "127.0.0.1:6379,password=,defaultDatabase=6"
}
}TaskSchedulerConfig Task Scheduler Configuration
Config file:
TaskSchedulersection inConfigs/appsettings.json
Settings
| Setting | Type | Description |
|---|---|---|
ProcessStartInfo | object | Process startup information |
ProcessStartInfo.FileName | string | Application path, e.g. C:/grpcurl_1.8.7/grpcurl |
ProcessStartInfo.WorkingDirectory | string | Working directory |
AlerEmail | object | Alert email configuration |
AlerEmail.Enable | bool | Enable alert emails |
AlerEmail.Address | string | Alert email address |
Modules | object[] | Module list |
Modules[].Name | string | Module name, e.g. admin |
Modules[].HttpUrl | string | HTTP URL, e.g. http://localhost:18010 |
Modules[].GrpcUrl | string | gRPC URL, e.g. http://localhost:18011 |
Configuration Example
json
{
"TaskScheduler": {
"ProcessStartInfo": {
"FileName": "C:/grpcurl_1.8.7/grpcurl",
"WorkingDirectory": ""
},
"AlerEmail": {
"Enable": true,
"Address": ""
},
"Modules": [
{
"Name": "admin",
"HttpUrl": "http://localhost:18010",
"GrpcUrl": "http://localhost:18011"
}
]
}
}RateLimitConfig Rate Limiting Configuration
Config file:
Configs/ratelimitconfig.json
Settings
| Setting | Type | Description |
|---|---|---|
Enable | bool | Enable rate limiting |
Method | string | Rate limit method: Client (client limiting) / Ip (IP limiting) |
ClientIdType | string | Client ID type: Token / UserId / ClientIdHeader |
CachePrefix | string | Cache prefix |
IpRateLimiting | object | IP rate limiting configuration |
IpRateLimiting.EnableEndpointRateLimiting | bool | Enable endpoint rate limiting |
IpRateLimiting.StackBlockedRequests | bool | Stack blocked requests |
IpRateLimiting.RealIpHeader | string | Real IP header |
IpRateLimiting.IpWhitelist | string[] | IP whitelist |
IpRateLimiting.EndpointWhitelist | string[] | Endpoint whitelist |
IpRateLimiting.ClientWhitelist | string[] | Client whitelist |
IpRateLimiting.HttpStatusCode | int | HTTP status code when limited |
IpRateLimiting.QuotaExceededResponse | object | Quota exceeded response content |
IpRateLimiting.GeneralRules | object[] | General rate limiting rules |
ClientRateLimiting | object | Client rate limiting configuration |
ClientRateLimiting.EnableEndpointRateLimiting | bool | Enable endpoint rate limiting |
ClientRateLimiting.ClientIdHeader | string | Client ID header |
ClientRateLimiting.IpWhitelist | string[] | IP whitelist |
ClientRateLimiting.EndpointWhitelist | string[] | Endpoint whitelist |
ClientRateLimiting.ClientWhitelist | string[] | Client whitelist |
ClientRateLimiting.HttpStatusCode | int | HTTP status code when limited |
ClientRateLimiting.QuotaExceededResponse | object | Quota exceeded response content |
ClientRateLimiting.GeneralRules | object[] | General rate limiting rules |
Configuration Example
json
{
"RateLimitConfig": {
"Enable": false,
"Method": "Client",
"ClientIdType": "Token",
"CachePrefix": "zhontai:ratelimit",
"IpRateLimiting": {
"EnableEndpointRateLimiting": true,
"StackBlockedRequests": false,
"RealIpHeader": "X-Real-IP",
"IpWhitelist": [],
"EndpointWhitelist": [
"get:/api/admin/auth/refresh",
"*:/*.*GrpcService/*"
],
"ClientWhitelist": [],
"HttpStatusCode": 429,
"QuotaExceededResponse": {
"Content": "{\"code\":429,\"msg\":\"Too many requests!\",\"success\": false}",
"ContentType": "application/json; charset=utf-8",
"StatusCode": 429
},
"GeneralRules": [
{
"Endpoint": "*:/api/*",
"Period": "1s",
"Limit": 3
},
{
"Endpoint": "*:/api/*",
"Period": "10m",
"Limit": 200
}
]
},
"ClientRateLimiting": {
"EnableEndpointRateLimiting": true,
"ClientIdHeader": "X-ClientId",
"IpWhitelist": [],
"EndpointWhitelist": [
"get:/api/admin/auth/refresh",
"*:/*.*GrpcService/*"
],
"ClientWhitelist": [],
"HttpStatusCode": 429,
"QuotaExceededResponse": {
"Content": "{\"code\":429,\"msg\":\"Too many requests!\",\"success\": false}",
"ContentType": "application/json; charset=utf-8",
"StatusCode": 429
},
"GeneralRules": [
{
"Endpoint": "*:/api/*",
"Period": "1s",
"Limit": 3
},
{
"Endpoint": "*:/api/*",
"Period": "10m",
"Limit": 200
}
]
}
}
}