From 70f85f95901da4cbd5a30b22a84825f036b42e5c Mon Sep 17 00:00:00 2001 From: henrygd Date: Thu, 29 Jan 2026 19:28:27 -0500 Subject: [PATCH] fix SHARE_ALL_SYSTEMS for system_details, smart_devices, and systemd_services (#1660) --- internal/hub/hub.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/internal/hub/hub.go b/internal/hub/hub.go index c24688d0..82b21f44 100644 --- a/internal/hub/hub.go +++ b/internal/hub/hub.go @@ -194,7 +194,34 @@ func setCollectionAuthSettings(app core.App) error { } containersListRule := strings.Replace(systemsReadRule, "users.id", "system.users.id", 1) containersCollection.ListRule = &containersListRule - return app.Save(containersCollection) + if err := app.Save(containersCollection); err != nil { + return err + } + + // allow all users to access system-related collections if SHARE_ALL_SYSTEMS is set + // these collections all have a "system" relation field + systemRelatedCollections := []string{"system_details", "smart_devices", "systemd_services"} + for _, collectionName := range systemRelatedCollections { + collection, err := app.FindCollectionByNameOrId(collectionName) + if err != nil { + return err + } + collection.ListRule = &containersListRule + // set viewRule for collections that need it (system_details, smart_devices) + if collection.ViewRule != nil { + collection.ViewRule = &containersListRule + } + // set deleteRule for smart_devices (allows user to dismiss disk warnings) + if collectionName == "smart_devices" { + deleteRule := containersListRule + " && @request.auth.role != \"readonly\"" + collection.DeleteRule = &deleteRule + } + if err := app.Save(collection); err != nil { + return err + } + } + + return nil } // registerCronJobs sets up scheduled tasks