Skip to content

Commit 0d1ab70

Browse files
committed
PR(AAC): Gate Schema Add
1 parent 96fcd7e commit 0d1ab70

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

acp/types/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const (
8888
AdminAACStatusPerm
8989
AdminAACRelationAddPerm
9090
AdminAACRelationDeletePerm
91+
AdminSchemaAddPerm
9192
)
9293

9394
// List of all valid resource interface permissions for admin access control, the order of
@@ -108,6 +109,7 @@ var RequiredResourcePermissionsForAdmin = []string{
108109
"aac-status",
109110
"aac-relation-add",
110111
"aac-relation-delete",
112+
"schema-add",
111113
}
112114

113115
const InternalAdminACPObjectToGate = "NodeObject"
@@ -152,6 +154,8 @@ resources:
152154
expr: owner + admin
153155
aac-relation-delete:
154156
expr: owner + admin
157+
schema-add:
158+
expr: owner + admin
155159
156160
relations:
157161
owner:

internal/db/store.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
"github.com/sourcenetwork/immutable"
1919

20+
acpTypes "github.com/sourcenetwork/defradb/acp/types"
2021
"github.com/sourcenetwork/defradb/client"
2122
)
2223

@@ -142,6 +143,11 @@ func (db *DB) AddSchema(ctx context.Context, schemaString string) ([]client.Coll
142143
ctx, span := tracer.Start(ctx)
143144
defer span.End()
144145

146+
err := db.checkAdminAccess(ctx, acpTypes.AdminSchemaAddPerm)
147+
if err != nil {
148+
return nil, err
149+
}
150+
145151
ctx, txn, err := ensureContextTxn(ctx, db, false)
146152
if err != nil {
147153
return nil, err

0 commit comments

Comments
 (0)