package config import ( "time" ) // Config 權限系統配置 type Config struct { JWT JWTConfig `json:"jwt"` Database DatabaseConfig `json:"database"` Casbin CasbinConfig `json:"casbin"` } // JWTConfig JWT 配置 type JWTConfig struct { Secret string `json:"secret"` AccessExpires time.Duration `json:"access_expires"` RefreshExpires time.Duration `json:"refresh_expires"` } // DatabaseConfig 數據庫配置 type DatabaseConfig struct { URI string `json:"uri"` Database string `json:"database"` Timeout time.Duration `json:"timeout"` } // CasbinConfig Casbin 配置 type CasbinConfig struct { ModelPath string `json:"model_path"` // RBAC 模型文件路徑 AutoSave bool `json:"auto_save"` // 自動保存策略 AutoLoad bool `json:"auto_load"` // 自動載入策略 AutoLoadDuration time.Duration `json:"auto_load_duration"` // 自動載入間隔 } // DefaultConfig 返回默認配置 func DefaultConfig() Config { return Config{ JWT: JWTConfig{ Secret: "your-secret-key", AccessExpires: time.Hour * 2, // 2 小時 RefreshExpires: time.Hour * 24 * 7, // 7 天 }, Casbin: CasbinConfig{ ModelPath: "etc/rbac_model.conf", AutoSave: true, AutoLoad: true, AutoLoadDuration: time.Second * 10, }, } }