feat: add role management with roles and permissions configuration
This commit is contained in:
parent
e69e1623b5
commit
e917953d6c
Binary file not shown.
|
|
@ -33,6 +33,8 @@ import (
|
|||
func main() {
|
||||
loadDotEnv(".env")
|
||||
|
||||
config.TestRoleYAML()
|
||||
|
||||
seedCount := flag.Int("seed", 0, "seed N fake users at startup (0 to skip)")
|
||||
flag.Parse()
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
role: admin
|
||||
permissions: 0
|
||||
roles:
|
||||
- role: manager
|
||||
permissions: 0
|
||||
roles:
|
||||
- role: user
|
||||
permissions: 0
|
||||
roles:
|
||||
- role: guest
|
||||
permissions: 0
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package auth
|
||||
|
||||
type Permission int
|
||||
type Role struct {
|
||||
Name string
|
||||
Permissions Permission
|
||||
}
|
||||
|
||||
const (
|
||||
AdminPermission Permission = 0xff - (1<<iota - 1)
|
||||
ManagerPermission
|
||||
UserPermission
|
||||
GuestPermission
|
||||
)
|
||||
|
||||
var Roles = []Role{
|
||||
{"admin", AdminPermission},
|
||||
{"manager", ManagerPermission},
|
||||
{"user", UserPermission},
|
||||
{"guest", GuestPermission},
|
||||
}
|
||||
Loading…
Reference in New Issue