Documentation ¶
Index ¶
Constants ¶
View Source
const ( ACT_RES_READ int8 = 1 // 针对资源型客体 ACT_RES_WRITE int8 = 2 // 针对资源型客体 ACT_API_ACCESS int8 = 3 // 针对接口型客体 OBJ_TYPE_RES objType = 1 // 客体类型:资源 OBJ_TYPE_API objType = 2 // 客体类型:接口 )
View Source
const ( MethodGet httpmethod = "GET" MethodHead httpmethod = "HEAD" MethodPost httpmethod = "POST" MethodPut httpmethod = "PUT" MethodPatch httpmethod = "PATCH" // RFC 5789 MethodDelete httpmethod = "DELETE" MethodConnect httpmethod = "CONNECT" MethodOptions httpmethod = "OPTIONS" MethodTrace httpmethod = "TRACE" )
Variables ¶
View Source
var ( ErrNoCustomerInfo error = errors.New("无法获取用户信息") ErrNoApiPolicy error = errors.New("接口权限不足") ErrPolicyNotFound error = errors.New("找不到权限信息") )
View Source
var (
IsServerRunning bool
)
Functions ¶
func GetAllPolicy ¶ added in v0.1.2
func GetSecurityHandler ¶
func GetSecurityHandler() gin.HandlerFunc
Types ¶
type Policy ¶
type Policy struct { Sub string `json:"sub"` // 主体,标签值 ObjType objType `json:"objType"` // 客体类型 Obj string `json:"obj"` // 客体 Act int8 `json:"act"` // 操作 }
权限
type Role ¶
type Role struct { database.BaseModel Name string `json:"name" gorm:"column:name;type:varchar(256);comment:角色名称"` Description string `json:"description" gorm:"column:description;type:varchar(1024);comment:描述"` RolePolicies []RolePolicy `json:"rolePolicies,omitempty" gorm:"foreignKey:rid;references:id;comment:权限"` ParentId int `json:"parentId,omitempty" gorm:"column:parent_id;comment:父级角色ID"` Parent *Role `json:"parent,omitempty" gorm:"foreignKey:id;references:parent_id;comment:父级角色"` Children []Role `json:"children,omitempty" gorm:"foreignKey:parent_id;references:id;comment:子级角色"` }
type RolePolicy ¶
type RolePolicy struct { RoleId int `gorm:"column:rid;comment:角色ID"` PolicySub string `gorm:"column:policy_sub;comment:权限主体标记"` Policies []Policy `json:"policies,omitempty" gorm:"-"` // gorm:"foreignKey:id;references:policy_id;comment:权限"` }
func (RolePolicy) TableName ¶
func (RolePolicy) TableName() string
type Router ¶
type Router struct { Method httpmethod SubTag string RelativePath string Handler gin.HandlerFunc }
type SecurityConfig ¶
type SecurityConfig struct { Enable bool `mapstructure:"enable" json:"enable" yaml:"enable"` // 是否开启 EnableRedisCache bool `mapstructure:"enable-redis-cache" json:"enableRedisCache" yaml:"enable-redis-cache"` // 是否开启redis缓存 }
func (SecurityConfig) Load ¶
func (c SecurityConfig) Load()
Click to show internal directories.
Click to hide internal directories.