-
Notifications
You must be signed in to change notification settings - Fork 96
/
casbin_policy_auth.go
55 lines (45 loc) · 1.41 KB
/
casbin_policy_auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package db
import (
"database/sql/driver"
"encoding/json"
)
type (
CasbinPolicyObject struct {
URL *string `json:"url,omitempty"`
AppName *string `json:"app_name,omitempty"`
Menu *string `json:"menu,omitempty"`
}
CasbinPolicyType string
CasbinPolicyAuth struct {
ModelT
Sub string `gorm:"not null;"json:"sub"`
Obj string `gorm:"type:varchar(255);not null;"json:"obj"`
Act string `gorm:"type:varchar(255);not null;"json:"act"`
Type CasbinPolicyType `gorm:"not null;"json:"type"`
}
)
var (
CasbinPolicyTypeMenu CasbinPolicyType = "menu"
CasbinPolicyTypeApp CasbinPolicyType = "app"
CasbinPolicyTypeAPI CasbinPolicyType = "api"
CasbinPolicyTypeMonitor CasbinPolicyType = "monitor" // Grafana权限
// 监控面板权限
MonitorPermWrite = "monitor:write"
AppPermAppRead = "app:read"
AppPermConfigRead = "config:read"
AppPermConfigWrite = "config:write"
AppPermConfigReadInstance = "config:readInstance"
AppPermMonitorRead = "monitor:read"
AppPermPProfRead = "pprof:read"
AppPermPProfRun = "pprof:run"
)
func (c CasbinPolicyAuth) TableName() string {
return "casbin_policy_auth"
}
func (c *CasbinPolicyObject) Scan(src interface{}) error {
return json.Unmarshal(src.([]byte), c)
}
func (c CasbinPolicyObject) Value() (driver.Value, error) {
val, err := json.Marshal(c)
return string(val), err
}