Documentation
¶
Index ¶
- Constants
- func Byte2Int(data []byte) int
- func CreateUUID() string
- func GetMd5str(value string) string
- func GetNowDate() string
- func Int2BytesTo(v int, ret []byte)
- func Min(a, b int) int
- func ToDate(t time.Time) string
- func ToInt(value string) int64
- type AccessContent
- type AccessLogger
- type AccessToken
- type Application
- type AuthClass
- type AuthField
- type AuthFieldValue
- type Authobject
- type AuthobjectSet
- type DefaultRoleMetaManager
- type ErrorContent
- type FieldType
- type HttpMethod
- type HttpStatus
- type Logger
- type Role
- type RoleManager
- type RoleMetaManager
- type TokenManager
- type TokenStore
- type ValueType
Constants ¶
View Source
const ( HM_GET = 10 HM_POST = 11 HM_DEL = 12 )
View Source
const ( HS_200 = 200 HS_404 = 404 )
View Source
const MAX_LEVEL = 10
安全模型
Variables ¶
This section is empty.
Functions ¶
func CreateUUID ¶
func CreateUUID() string
func GetNowDate ¶
func GetNowDate() string
func Int2BytesTo ¶
Types ¶
type AccessContent ¶
type AccessContent struct { Remote string //记录访问网站的客户端地址 TimeStart time.Time //记录访问时间 Request string //用户的http请求起始行信息 BodySent int64 //服务器发送给客户端的响应body字节数 Status HttpStatus //http状态码,记录请求返回的状态码,例如:200、301、404等 Referer string //记录此次请求是从哪个连接访问过来的,可以根据该参数进行防盗链设置。 Url string //访问的URL地址 Method HttpMethod //访问的方法 GET POST DELETE Agent string //记录客户端访问信息,例如:浏览器、手机客户端等 TimeEnd time.Time //记录访问结束时间 }
访问日志
type AccessLogger ¶
type AccessLogger interface { //服务访问 ToAccess(content *AccessContent) //服务访问错误信息记录 ToError(e *ErrorContent) WriteTextToAccess(text string) }
type AccessToken ¶
访问token
func (*AccessToken) IsExpire ¶
func (this *AccessToken) IsExpire(expire int64) bool
type Application ¶
type Application interface { ReloadAuth() //重新加载权限 Restart() //重启 ShutdownNotify() //关闭通知 PauseService() RestoreService() ReloadConfig() ReloadApis() }
应用接口
type AuthFieldValue ¶
type AuthFieldValue struct { Field *AuthField //字段名称 Type ValueType //取值类型:单值、区间、枚举 Value string //取值范围 Values []string }
权限值
func (*AuthFieldValue) Validate ¶
func (this *AuthFieldValue) Validate(v string) bool
type AuthobjectSet ¶
type AuthobjectSet struct { Class *AuthClass Objects []*Authobject ReverseObject []*Authobject }
权限对象集合
func (*AuthobjectSet) AddAuthObject ¶
func (this *AuthobjectSet) AddAuthObject(reverse bool, values []*AuthFieldValue)
func (*AuthobjectSet) BuildFieldValue ¶
func (this *AuthobjectSet) BuildFieldValue(name string, t ValueType, v string) *AuthFieldValue
type DefaultRoleMetaManager ¶
type DefaultRoleMetaManager struct {
// contains filtered or unexported fields
}
func (*DefaultRoleMetaManager) AddRole ¶
func (this *DefaultRoleMetaManager) AddRole(r *Role)
func (*DefaultRoleMetaManager) FindRole ¶
func (this *DefaultRoleMetaManager) FindRole(name string) *Role
type ErrorContent ¶
type ErrorContent struct { AccessContent ErrorCode string //错误码 ErrorMessage string //错误消息内容 Descript string //返回结果摘要 }
type Role ¶
type Role struct { SuperRole *Role //继承的角色 Code string //角色名称 // contains filtered or unexported fields }
角色
type RoleManager ¶
type RoleManager struct {
// contains filtered or unexported fields
}
角色管理
func (*RoleManager) SetMetaManager ¶
func (this *RoleManager) SetMetaManager(m RoleMetaManager)
type TokenManager ¶
type TokenManager struct { Expire int64 //过期时间 Store TokenStore }
func (*TokenManager) CreateToken ¶
func (this *TokenManager) CreateToken(user string, role string) (*AccessToken, string)
func (*TokenManager) GetToken ¶
func (this *TokenManager) GetToken(id string) *AccessToken
type TokenStore ¶
type TokenStore interface { //获取token GetToken(id string) *AccessToken //保存token SaveToken(id string, t *AccessToken, expire int64) }
Click to show internal directories.
Click to hide internal directories.