47 lines
796 B
Go
47 lines
796 B
Go
package config
|
|
|
|
import "time"
|
|
|
|
// RBACConfig RBAC 配置
|
|
type RBACConfig struct {
|
|
ModelPath string
|
|
SyncPeriod time.Duration
|
|
EnableCache bool
|
|
}
|
|
|
|
// RoleConfig 角色配置
|
|
type RoleConfig struct {
|
|
// UID 前綴 (例如: AM, RL)
|
|
UIDPrefix string
|
|
|
|
// UID 數字長度
|
|
UIDLength int
|
|
|
|
// 管理員角色 UID
|
|
AdminRoleUID string
|
|
|
|
// 管理員用戶 UID
|
|
AdminUserUID string
|
|
|
|
// 預設角色名稱
|
|
DefaultRoleName string
|
|
}
|
|
|
|
// DefaultConfig 預設配置
|
|
func DefaultConfig() Config {
|
|
return Config{
|
|
RBAC: RBACConfig{
|
|
ModelPath: "./rbac_model.conf",
|
|
SyncPeriod: 30 * time.Second,
|
|
EnableCache: true,
|
|
},
|
|
Role: RoleConfig{
|
|
UIDPrefix: "AM",
|
|
UIDLength: 6,
|
|
AdminRoleUID: "AM000000",
|
|
AdminUserUID: "B000000",
|
|
DefaultRoleName: "USER",
|
|
},
|
|
}
|
|
}
|