haibei/configs/dev/middleware.toml
2025-06-19 10:33:58 +08:00

76 lines
1.8 KiB
TOML

[Middleware]
[Middleware.Recovery]
Skip = 3
[Middleware.CORS]
Enable = true
AllowOrigins = ["*"]
AllowMethods = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]
AllowHeaders = ["*"]
MaxAge = 86400
AllowWildcard = true
AllowWebSockets = true
AllowFiles = true
[Middleware.Trace]
RequestHeaderKey = "X-Request-Id"
ResponseTraceKey = "X-Trace-Id"
[Middleware.Logger]
MaxOutputRequestBodyLen = 4096 # bytes
MaxOutputResponseBodyLen = 4096 # bytes
[Middleware.CopyBody]
MaxContentLen = 134217728 # 128MB
[Middleware.Auth]
Disable = false
SkippedPathPrefixes = ["/api/v1/captcha/", "/api/v1/login","/api/v1/apps/login"]
SigningMethod = "HS512" # HS256/HS384/HS512
SigningKey = "XnEsT0S@" # Secret key
OldSigningKey = "" # Old secret key (For change secret key)
Expired = 86400 # seconds
[Middleware.Auth.Store]
Type = "badger" # memory/badger/redis
Delimiter = ":"
[Middleware.Auth.Store.Memory]
CleanupInterval = 60 # seconds
[Middleware.Auth.Store.Badger]
Path = "data/auth"
[Middleware.Auth.Store.Redis]
Addr = "115.239.217.220:6379" # If empty, then use the same configuration as Storage.Cache.Redis
Username = ""
Password = "123456"
DB = 2
[Middleware.RateLimiter]
Enable = false
Period = 10 # seconds
MaxRequestsPerIP = 1000
MaxRequestsPerUser = 500
[Middleware.RateLimiter.Store]
Type = "redis" # memory/redis
[Middleware.RateLimiter.Store.Memory]
Expiration = 3600
CleanupInterval = 60
[Middleware.RateLimiter.Store.Redis]
Addr = "115.239.217.220:6379" # If empty, then use the same configuration as Storage.Cache.Redis
Username = ""
Password = "123456"
DB = 10
[Middleware.Casbin]
Disable = true
SkippedPathPrefixes = ["/api/v1/captcha/", "/api/v1/login", "/api/v1/current/"]
LoadThread = 2
AutoLoadInterval = 3 # seconds
ModelFile = "rbac_model.conf"
GenPolicyFile = "gen_rbac_policy.csv"