Skip to content

Lightweight server monitoring with historical data, docker stats, and alerts.

fix(hub): prevent readonly users listing tokens of their shared systems via api

henrygde39e153ca01f
diff --git a/internal/hub/collections.go b/internal/hub/collections.go
index eb88da62e..667f4bf8e 100644
--- a/internal/hub/collections.go
+++ b/internal/hub/collections.go
@@ -99,8 +99,8 @@ func setCollectionAuthSettings(app core.App) error {
}
if err := applyCollectionRules(app, []string{"fingerprints"}, collectionRules{
- list: &systemScopedReadRule,
- view: &systemScopedReadRule,
+ list: &systemScopedWriteRule,
+ view: &systemScopedWriteRule,
create: &systemScopedWriteRule,
update: &systemScopedWriteRule,
delete: &systemScopedWriteRule,
diff --git a/internal/hub/collections_test.go b/internal/hub/collections_test.go
index 0bbf0604c..969b27828 100644
--- a/internal/hub/collections_test.go
+++ b/internal/hub/collections_test.go
@@ -88,8 +88,8 @@ func TestCollectionRulesDefault(t *testing.T) {
// fingerprints collection
fingerprintsCollection, err := hub.FindCollectionByNameOrId("fingerprints")
require.NoError(t, err, "Failed to find fingerprints collection")
- assert.Equal(t, isUserInSystemUsers, *fingerprintsCollection.ListRule)
- assert.Equal(t, isUserInSystemUsers, *fingerprintsCollection.ViewRule)
+ assert.Equal(t, isUserInSystemUsersNotReadonly, *fingerprintsCollection.ListRule)
+ assert.Equal(t, isUserInSystemUsersNotReadonly, *fingerprintsCollection.ViewRule)
assert.Equal(t, isUserInSystemUsersNotReadonly, *fingerprintsCollection.CreateRule)
assert.Equal(t, isUserInSystemUsersNotReadonly, *fingerprintsCollection.UpdateRule)
assert.Equal(t, isUserInSystemUsersNotReadonly, *fingerprintsCollection.DeleteRule)
@@ -216,8 +216,8 @@ func TestCollectionRulesShareAllSystems(t *testing.T) {
// fingerprints collection
fingerprintsCollection, err := hub.FindCollectionByNameOrId("fingerprints")
require.NoError(t, err, "Failed to find fingerprints collection")
- assert.Equal(t, isUser, *fingerprintsCollection.ListRule)
- assert.Equal(t, isUser, *fingerprintsCollection.ViewRule)
+ assert.Equal(t, isUserNotReadonly, *fingerprintsCollection.ListRule)
+ assert.Equal(t, isUserNotReadonly, *fingerprintsCollection.ViewRule)
assert.Equal(t, isUserNotReadonly, *fingerprintsCollection.CreateRule)
assert.Equal(t, isUserNotReadonly, *fingerprintsCollection.UpdateRule)
assert.Equal(t, isUserNotReadonly, *fingerprintsCollection.DeleteRule)