grants: every mesh account may publish and subscribe on every subject

The operator, 2026-11-15 23:12 CET: the mesh accounts should have all the permissions, otherwise it becomes a mess;
the operator can do everything, always. Permissions derived per module refused the indexer's chunks, seat asks and
seat verbs again and again while G is delivered. The approval mark's and the desk's denies stay; an enrolling node
keeps its few subjects. The research after G replaces the accounts themselves (mesh, agent, operator).
This commit is contained in:
2026-11-15 23:14:36 +01:00
parent 7c33a2cf4c
commit e1476cfdf9
5 changed files with 43 additions and 0 deletions
@@ -1688,3 +1688,18 @@ func TestWatchedEventSubjectTakesTheDefinitionsParts(t *testing.T) {
}
}
}
// TestEveryMeshAccountMayDoEverything is the operator's word of 2026-11-15 23:12 CET: a mesh account publishes and subscribes on
// every subject, the approval mark's denies kept; an enrolling node keeps its few subjects.
func TestEveryMeshAccountMayDoEverything(t *testing.T) {
EveryAccountMayDoEverything = true
defer func() { EveryAccountMayDoEverything = false }()
m, err := PermissionsFor(Principal{Kind: KindModule, Node: "a", Module: "plain"})
if err != nil || !slices.Equal(m.Publish, []string{AllSubjects}) || !slices.Equal(m.Subscribe, []string{AllSubjects}) {
t.Fatalf("a module account = %v / %v (%v), want every subject both ways", m.Publish, m.Subscribe, err)
}
e, err := PermissionsFor(Principal{Kind: KindEnrolment, Node: "new"})
if err == nil && slices.Contains(e.Publish, AllSubjects) {
t.Errorf("an enrolling node is granted every subject: %v", e.Publish)
}
}
@@ -711,6 +711,19 @@ var BusSnapshotGrants = struct{ Publish []string }{Publish: []string{
// PermissionsFor derives a principal's authority. Pure, and the only place authority is decided:
// a permission that cannot be derived from a declaration is a permission nobody can explain.
func PermissionsFor(p Principal) (Permissions, error) {
perms, err := scopedPermissionsFor(p)
// **Every account of the mesh may do everything** (the operator, 2026-11-15 23:12 CET: "the mesh accounts should have all the
// permissions, otherwise it will become a mess"; "the operator can do everything, always"): publish and subscribe on every
// subject. The denies stay: they are the approval mark's and the desk's, not permissions. An enrolling node is not of the mesh
// yet and keeps its few subjects. Until the research after G replaces the accounts themselves (mesh, agent, operator).
if err == nil && EveryAccountMayDoEverything && p.Kind != KindEnrolment {
perms.Publish, perms.Subscribe = []string{AllSubjects}, []string{AllSubjects}
}
return perms, err
}
// scopedPermissionsFor is each account's own subjects, as composed before every account was given every subject.
func scopedPermissionsFor(p Principal) (Permissions, error) {
perms, err := permissionsFor(p)
if err != nil || p.SnapshotsTheBus && p.Kind == KindModule {
return perms, err
@@ -743,6 +756,13 @@ func PermissionsFor(p Principal) (Permissions, error) {
return perms, nil
}
// AllSubjects is every subject of the bus.
const AllSubjects = ">"
// EveryAccountMayDoEverything widens every account but an enrolling node's to AllSubjects. On in the part; the tests of each
// account's own subjects turn it off in their TestMain, since that composition still runs beneath it.
var EveryAccountMayDoEverything = true
// NewEventGrants are what hearing a new event on each stream through an ordered consumer needs, in the forms the client library
// sends: the create of a consumer the client names itself (with its filter or without, as it has one filter subject or several), its
// info and its delete, the next-message fetch, and the flow control (design 47 G A-384). The whole of each stream's subjects: inside the mesh
@@ -11,5 +11,7 @@ import (
// TestMain gives catalogue the seat list a host reads (ADR 0636 §1): none is compiled into mesh-sdk.
func TestMain(m *testing.M) {
catalogue.UseSeats(catalogue.SeatsFromDefinitions(seatlisttest.Definitions()))
// These tests read each account's own subjects, which the part composes beneath the wide grant.
EveryAccountMayDoEverything = false
os.Exit(m.Run())
}
@@ -1,6 +1,7 @@
package grants
import (
"mesh-grants/internal/buscompose"
"os"
"testing"
@@ -11,5 +12,7 @@ import (
// TestMain gives catalogue the seat list a host reads (ADR 0636 §1): none is compiled into mesh-sdk.
func TestMain(m *testing.M) {
catalogue.UseSeats(catalogue.SeatsFromDefinitions(seatlisttest.Definitions()))
// These tests read each account's own subjects, which the part composes beneath the wide grant.
buscompose.EveryAccountMayDoEverything = false
os.Exit(m.Run())
}
+3
View File
@@ -1,6 +1,7 @@
package manifest
import (
"mesh-grants/internal/buscompose"
"os"
"testing"
@@ -11,5 +12,7 @@ import (
// TestMain gives catalogue the seat list a host reads (ADR 0636 §1): none is compiled into mesh-sdk.
func TestMain(m *testing.M) {
catalogue.UseSeats(catalogue.SeatsFromDefinitions(seatlisttest.Definitions()))
// These tests read each account's own subjects, which the part composes beneath the wide grant.
buscompose.EveryAccountMayDoEverything = false
os.Exit(m.Run())
}