Documentation
¶
Index ¶
- Constants
- func PasswordEncryptTypes() []maps.Map
- type AdminConfig
- func (this *AdminConfig) AddGrant(grant *AdminGrant)
- func (this *AdminConfig) AddRole(role *AdminRole)
- func (this *AdminConfig) AddUser(user *AdminUser)
- func (this *AdminConfig) AllowIP(ip string) bool
- func (this *AdminConfig) ComparePassword(inputPassword, encryptedPassword string) bool
- func (this *AdminConfig) ContainsActiveUser(username string) bool
- func (this *AdminConfig) ContainsUser(username string) bool
- func (this *AdminConfig) EncryptPassword(password string) string
- func (this *AdminConfig) FindActiveGrant(grantCode string) *AdminGrant
- func (this *AdminConfig) FindActiveRole(roleCode string) *AdminRole
- func (this *AdminConfig) FindActiveUser(username string) *AdminUser
- func (this *AdminConfig) FindAllActiveGrants() []*AdminGrant
- func (this *AdminConfig) FindAllActiveRoles() []*AdminRole
- func (this *AdminConfig) FindRole(roleCode string) *AdminRole
- func (this *AdminConfig) FindUser(username string) *AdminUser
- func (this *AdminConfig) FindUserWithKey(key string) *AdminUser
- func (this *AdminConfig) Reset()
- func (this *AdminConfig) Save() error
- func (this *AdminConfig) Validate() error
- type AdminGrant
- type AdminRole
- type AdminSecurity
- type AdminUser
Constants ¶
View Source
const ( // 内置权限 AdminGrantAll = "all" AdminGrantProxy = "proxy" AdminGrantQ = "q" AdminGrantApi = "api" AdminGrantLog = "log" AdminGrantAgent = "agent" AdminGrantPlugin = "plugin" AdminGrantTeam = "team" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdminConfig ¶
type AdminConfig struct {
// 安全设置
Security *AdminSecurity `yaml:"security" json:"security"`
// 角色
Roles []*AdminRole `yaml:"roles" json:"roles"`
// 权限
Grant []*AdminGrant `yaml:"grant" json:"grant"`
// 用户
Users []*AdminUser `yaml:"users" json:"users"`
}
管理员配置
func (*AdminConfig) ComparePassword ¶ added in v0.1.9
func (this *AdminConfig) ComparePassword(inputPassword, encryptedPassword string) bool
对比密码
func (*AdminConfig) ContainsActiveUser ¶
func (this *AdminConfig) ContainsActiveUser(username string) bool
是否包含某个激活的用户名
func (*AdminConfig) ContainsUser ¶
func (this *AdminConfig) ContainsUser(username string) bool
是否包含某个用户名
func (*AdminConfig) EncryptPassword ¶ added in v0.1.9
func (this *AdminConfig) EncryptPassword(password string) string
加密密码
func (*AdminConfig) FindActiveGrant ¶
func (this *AdminConfig) FindActiveGrant(grantCode string) *AdminGrant
根据代号查找权限
func (*AdminConfig) FindActiveRole ¶
func (this *AdminConfig) FindActiveRole(roleCode string) *AdminRole
根据代号查找激活的角色
func (*AdminConfig) FindActiveUser ¶
func (this *AdminConfig) FindActiveUser(username string) *AdminUser
使用用户名查找激活的用户
func (*AdminConfig) FindAllActiveGrants ¶
func (this *AdminConfig) FindAllActiveGrants() []*AdminGrant
取得所有内置的权限
func (*AdminConfig) FindAllActiveRoles ¶
func (this *AdminConfig) FindAllActiveRoles() []*AdminRole
查找激活的角色
func (*AdminConfig) FindRole ¶
func (this *AdminConfig) FindRole(roleCode string) *AdminRole
根据代号查找角色
func (*AdminConfig) FindUser ¶
func (this *AdminConfig) FindUser(username string) *AdminUser
使用用户名查找用户
func (*AdminConfig) FindUserWithKey ¶
func (this *AdminConfig) FindUserWithKey(key string) *AdminUser
使用Key查找用户
type AdminGrant ¶
type AdminGrant struct {
Name string `yaml:"name" json:"name"`
Code string `yaml:"code" json:"code"`
IsDisabled bool `yaml:"isDisabled" json:"isDisabled"`
}
权限定义
type AdminRole ¶
type AdminRole struct {
Name string `yaml:"name" json:"name"` // 名称
Code string `yaml:"code" json:"code"` // 代号
Grant []string `yaml:"grant" json:"grant"` // 授权
IsDisabled bool `yaml:"isDisabled" json:"isDisabled"` // 是否禁用
}
角色定义
type AdminSecurity ¶
type AdminSecurity struct {
TeaVersion string `yaml:"teaVersion" json:"teaVersion"`
Allow []string `yaml:"allow" json:"allow"` //支持的IP
Deny []string `yaml:"deny" json:"deny"` // 拒绝的IP
Secret string `yaml:"secret" json:"secret"` // 密钥
IsDisabled bool `yaml:"isDisabled" json:"isDisabled"` // 是否禁用
DirAutoComplete bool `yaml:"dirAutoComplete" json:"dirAutoComplete"` // 是否支持目录自动补全
LoginURL string `yaml:"loginURL" json:"loginURL"` // 登录页面的URL
PasswordEncryptType string `yaml:"passwordEncryptType" json:"passwordEncryptType"` // 密码加密方式
// contains filtered or unexported fields
}
安全设置定义
func (*AdminSecurity) AllowIP ¶ added in v0.1.9
func (this *AdminSecurity) AllowIP(ip string) bool
判断某个IP是否允许访问
func (*AdminSecurity) NewLoginURL ¶ added in v0.1.9
func (this *AdminSecurity) NewLoginURL() string
获取登录URL
func (*AdminSecurity) PasswordEncryptTypeText ¶ added in v0.1.9
func (this *AdminSecurity) PasswordEncryptTypeText() string
获取加密方式文字说明
type AdminUser ¶
type AdminUser struct {
Username string `yaml:"username" json:"username"` // 用户名
Password string `yaml:"password" json:"password"` // 密码
Role []string `yaml:"role" json:"role"` // 角色
Key string `yaml:"key" json:"key"` // Key,用来请求API等
Name string `yaml:"name" json:"name"` // 姓名
Avatar string `yaml:"avatar" json:"avatar"` // 头像
Tel string `yaml:"tel" json:"tel"` // 联系电话
CreatedAt int64 `yaml:"createdAt" json:"createdAt"` // 创建时间
LoggedAt int64 `yaml:"loggedAt" json:"loggedAt"` // 最后登录时间
LoggedIP string `yaml:"loggedIP" json:"loggedIP"` // 最后登录IP
Grant []string `yaml:"grant" json:"grant"` // 权限,会细化到项目,比如:apis:example.com
IsDisabled bool `yaml:"isDisabled" json:"isDisabled"` // 是否禁用
// contains filtered or unexported fields
}
管理员用户
func (*AdminUser) CountLoginTries ¶
func (*AdminUser) IncreaseLoginTries ¶
func (this *AdminUser) IncreaseLoginTries()
func (*AdminUser) ResetLoginTries ¶
func (this *AdminUser) ResetLoginTries()
Click to show internal directories.
Click to hide internal directories.