feat: add role management with roles and permissions configuration

This commit is contained in:
fabio 2026-03-24 20:12:35 +01:00
parent e69e1623b5
commit e917953d6c
5 changed files with 34 additions and 0 deletions

Binary file not shown.

View File

@ -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()

View File

View File

@ -0,0 +1,11 @@
role: admin
permissions: 0
roles:
- role: manager
permissions: 0
roles:
- role: user
permissions: 0
roles:
- role: guest
permissions: 0

View File

@ -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},
}