feat: frontend permissions and the merged-permission resolver

- PermissionSet reads the stored JSON tolerantly and writes an object
  of integers; FrontendPermission is the catalogue row
- MergedPermissions, HasPermission and UserHasPermission port PHP
  getMergedPermissions and Winter's hasPermission: groups merge with
  most positive wins, the user's own values override, held means
  exactly 1, wildcards as in Winter
- User gains Permissions (never serialized) and declares the avatar
  attachment relation the user API already writes
This commit is contained in:
Jakub Zych
2026-10-05 13:21:51 +02:00
parent 970eba7734
commit cdea47a178
5 changed files with 604 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package models
import "time"
// FrontendPermission is one row of golem15_user_frontend_permissions, the
// PHP FrontendPermission model: a permission the user and group permission
// editors offer. Rows come from migrations or seeds of the host application;
// there is no registry that plugins declare permissions in. Label, Tab and
// Comment are shown as stored; a value that is a translation key is
// translated.
type FrontendPermission struct {
ID uint `gorm:"column:id;primaryKey"`
Code string `gorm:"column:code"`
Label string `gorm:"column:label"`
Tab string `gorm:"column:tab"`
Comment *string `gorm:"column:comment"`
CreatedAt *time.Time `gorm:"column:created_at"`
UpdatedAt *time.Time `gorm:"column:updated_at"`
}
func (FrontendPermission) TableName() string { return "golem15_user_frontend_permissions" }
func init() {
Register(FrontendPermission{})
}