Skip to content

Commit 3b9b1b4

Browse files
committed
fix: Improve configuration files
1 parent 2fcee95 commit 3b9b1b4

File tree

4 files changed

+80
-34
lines changed

4 files changed

+80
-34
lines changed

configs/dev/logging.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Logger]
22
Debug = true
3-
Level = "debug"
3+
Level = "debug" # debug/info/warn/error/dpanic/panic/fatal
44
CallerSkip = 1
55

66
[Logger.File]
@@ -23,4 +23,4 @@ DSN = "data/ginadmin.db"
2323
MaxOpenConns = "16"
2424
MaxIdleConns = "4"
2525
MaxLifetime = "86400"
26-
MaxIdleTime = "7200"
26+
MaxIdleTime = "7200"

configs/dev/middleware.toml

+32-22
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@
33
[Middleware.Recovery]
44
Skip = 3
55

6-
[Middleware.Trace]
7-
RequestHeaderKey = "X-Request-Id"
8-
ResponseTraceKey = "X-Trace-Id"
9-
10-
[Middleware.Logger]
11-
MaxOutputRequestBodyLen = 4096 # bytes
12-
MaxOutputResponseBodyLen = 1024 # bytes
13-
14-
[Middleware.TokenAuth]
15-
Enable = true
16-
17-
[Middleware.CopyBody]
18-
MaxContentLen = 134217728 # 128MB
19-
206
[Middleware.CORS]
217
Enable = false
228
AllowOrigins = ["*"]
@@ -27,23 +13,46 @@ AllowWildcard = true
2713
AllowWebSockets = true
2814
AllowFiles = true
2915

16+
[Middleware.Trace]
17+
RequestHeaderKey = "X-Request-Id"
18+
ResponseTraceKey = "X-Trace-Id"
19+
20+
[Middleware.Logger]
21+
MaxOutputRequestBodyLen = 4096 # bytes
22+
MaxOutputResponseBodyLen = 4096 # bytes
23+
24+
[Middleware.CopyBody]
25+
MaxContentLen = 134217728 # 128MB
26+
3027
[Middleware.Auth]
3128
Disable = false
3229
SkippedPathPrefixes = ["/api/v1/captcha/", "/api/v1/login"]
30+
SigningMethod = "HS512" # HS256/HS384/HS512
31+
SigningKey = "XnEsT0S@" # Secret key
32+
OldSigningKey = "" # Old secret key (For change secret key)
33+
Expired = 86400 # seconds
3334

3435
[Middleware.Auth.Store]
35-
Type = "badger" # badger/redis
36+
Type = "badger" # memory/badger/redis
37+
Delimiter = ":"
38+
39+
[Middleware.Auth.Store.Memory]
40+
CleanupInterval = 60 # seconds
41+
42+
[Middleware.Auth.Store.Badger]
43+
Path = "data/auth"
3644

3745
[Middleware.Auth.Store.Redis]
38-
Addr = ""
46+
Addr = "" # If empty, then use the same configuration as Storage.Cache.Redis
3947
Username = ""
4048
Password = ""
4149
DB = 2
4250

4351
[Middleware.RateLimiter]
4452
Enable = false
45-
MaxRequestsPerIP = 30
46-
MaxRequestsPerUser = 30
53+
Period = 10 # seconds
54+
MaxRequestsPerIP = 1000
55+
MaxRequestsPerUser = 500
4756

4857
[Middleware.RateLimiter.Store]
4958
Type = "memory" # memory/redis
@@ -53,14 +62,15 @@ Expiration = 3600
5362
CleanupInterval = 60
5463

5564
[Middleware.RateLimiter.Store.Redis]
56-
Addr = ""
65+
Addr = "" # If empty, then use the same configuration as Storage.Cache.Redis
5766
Username = ""
5867
Password = ""
5968
DB = 10
6069

6170
[Middleware.Casbin]
6271
Disable = false
6372
SkippedPathPrefixes = ["/api/v1/captcha/", "/api/v1/login", "/api/v1/current/"]
64-
65-
[Middleware.Static]
66-
SkippedPathPrefixes = ["/api"]
73+
LoadThread = 2
74+
AutoLoadInterval = 3 # seconds
75+
ModelFile = "rbac_model.conf"
76+
GenPolicyFile = "gen_rbac_policy.csv"

configs/dev/server.toml

+37-7
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
[General]
22
AppName = "ginadmin"
3-
DebugMode = true
4-
PprofAddr = "localhost:6060"
3+
Version = "v10.0.2"
4+
Debug = true
5+
PprofAddr = "" # Pprof monitor address, "localhost:6060"
56
DisableSwagger = false
67
DisablePrintConfig = false
7-
MenuFile = "menu.json"
8+
DefaultLoginPwd = "6351623c8cef86fefabfa7da046fc619" # MD5("abc-123")
9+
MenuFile = "menu.json" # Or use "menu_cn.json"
10+
DenyDeleteMenu = false
811

912
[General.HTTP]
1013
Addr = ":8040"
14+
ShutdownTimeout = 10
1115
ReadTimeout = 60
1216
WriteTimeout = 60
1317
IdleTimeout = 10
14-
ShutdownTimeout = 10
1518
CertFile = ""
1619
KeyFile = ""
1720

18-
[General.Root]
21+
[General.Root] # Super Administrator Account
1922
ID = "root"
2023
Username = "admin"
21-
Password = "6351623c8cef86fefabfa7da046fc619" # abc-123
24+
Password = "6351623c8cef86fefabfa7da046fc619" # MD5("abc-123")
2225
Name = "Admin"
2326

2427
[Storage]
2528

2629
[Storage.Cache]
27-
Type = "badger" # badger/redis
30+
Type = "badger" # memory/badger/redis
2831
Delimiter = ":"
2932

3033
[Storage.Cache.Memory]
@@ -54,3 +57,30 @@ MaxOpenConns = 100
5457
MaxIdleConns = 50
5558
TablePrefix = ""
5659
AutoMigrate = true
60+
61+
[Util]
62+
63+
[Util.Captcha]
64+
Length = 4
65+
Width = 400
66+
Height = 160
67+
CacheType = "memory" # memory/redis
68+
69+
[Util.Captcha.Redis]
70+
Addr = "" # If empty, then use the same configuration as Storage.Cache.Redis
71+
Username = ""
72+
Password = ""
73+
DB = 1
74+
KeyPrefix = "captcha:"
75+
76+
[Util.Prometheus]
77+
Enable = false
78+
Port = 9100
79+
BasicUsername = "admin"
80+
BasicPassword = "admin"
81+
LogApis = [] # Log APIs, e.g. ["/api/v1/users"]
82+
LogMethods = [] # Log HTTP methods, e.g. ["GET"]
83+
DefaultCollect = true
84+
85+
[Dictionary]
86+
UserCacheExp = 4 # hours

internal/config/config.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ type Config struct {
1818

1919
type General struct {
2020
AppName string `default:"ginadmin"`
21-
Version string `default:"v1.0.0"`
21+
Version string `default:"v10.0.2"`
2222
Debug bool
2323
PprofAddr string
2424
DisableSwagger bool
2525
DisablePrintConfig bool
26-
DefaultLoginPwd string `default:"6351623c8cef86fefabfa7da046fc619"` // abc-123
26+
DefaultLoginPwd string `default:"6351623c8cef86fefabfa7da046fc619"` // MD5(abc-123)
2727
WorkDir string // From command arguments
2828
MenuFile string // From schema.Menus (JSON/YAML)
2929
DenyDeleteMenu bool
3030
HTTP struct {
31-
Addr string `default:":8080"`
31+
Addr string `default:":8040"`
3232
ShutdownTimeout int `default:"10"` // seconds
3333
ReadTimeout int `default:"60"` // seconds
3434
WriteTimeout int `default:"60"` // seconds
@@ -125,6 +125,12 @@ func (c *Config) PreLoad() {
125125
if addr := c.Storage.Cache.Redis.Addr; addr != "" {
126126
username := c.Storage.Cache.Redis.Username
127127
password := c.Storage.Cache.Redis.Password
128+
if c.Util.Captcha.CacheType == "redis" &&
129+
c.Util.Captcha.Redis.Addr == "" {
130+
c.Util.Captcha.Redis.Addr = addr
131+
c.Util.Captcha.Redis.Username = username
132+
c.Util.Captcha.Redis.Password = password
133+
}
128134
if c.Middleware.RateLimiter.Store.Type == "redis" &&
129135
c.Middleware.RateLimiter.Store.Redis.Addr == "" {
130136
c.Middleware.RateLimiter.Store.Redis.Addr = addr

0 commit comments

Comments
 (0)