package schutzaria import ( "errors" "strings" ) var groupPermissions = map[string]map[string]bool{ "read": {"read": true}, "read_write_once": {"read": true, "create": true, "upload": true}, "read_write": {"read": true, "create": true, "write": true, "upload": true, "rename": true, "link": true}, "upload_only": {"upload": true}, } func NormalizeGroupPermission(value string) (string, error) { value = strings.ToLower(strings.TrimSpace(value)) if _, ok := groupPermissions[value]; !ok { return "", errors.New("invalid group permission") } return value, nil } // GroupPermissionAllows evaluates a previously authenticated membership's // profile. Creation-only existence checks and principal state belong to callers. // This literal prefix rule deliberately preserves the existing stored scopes. func GroupPermissionAllows(scope, permission, capability, targetPath string) bool { inside := targetPath == scope || scope == "/" || strings.HasPrefix(targetPath, strings.TrimRight(scope, "/")+"/") return inside && groupPermissions[permission][capability] }