From 5f94f023ef5213dd1d4dd459e3ed78611207fa45 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sat, 19 Dec 2020 01:54:48 +0100 Subject: [PATCH] API: Refactor ACL --- internal/acl/permissions.go | 2 +- internal/acl/resources.go | 42 ++++++++++++++++++------------------- internal/api/config.go | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/acl/permissions.go b/internal/acl/permissions.go index a4932d020..1de234d61 100644 --- a/internal/acl/permissions.go +++ b/internal/acl/permissions.go @@ -8,7 +8,7 @@ var Permissions = ACL{ RoleAdmin: Actions{ActionDefault: true}, RoleGuest: Actions{ActionRead: true}, }, - ResourceOptions: Roles{ + ResourceConfigOptions: Roles{ RoleAdmin: Actions{ActionDefault: true}, }, ResourceAlbums: Roles{ diff --git a/internal/acl/resources.go b/internal/acl/resources.go index a2208ee7b..4cd6751fd 100644 --- a/internal/acl/resources.go +++ b/internal/acl/resources.go @@ -3,25 +3,25 @@ package acl type Resource string const ( - ResourceDefault Resource = "*" - ResourceConfig Resource = "config" - ResourceOptions Resource = "options" - ResourceSettings Resource = "settings" - ResourceLogs Resource = "logs" - ResourceAccounts Resource = "accounts" - ResourceAlbums Resource = "albums" - ResourceCameras Resource = "cameras" - ResourceCategories Resource = "categories" - ResourceCountries Resource = "countries" - ResourceFiles Resource = "files" - ResourceFolders Resource = "folders" - ResourceLabels Resource = "labels" - ResourceLenses Resource = "lenses" - ResourceLinks Resource = "links" - ResourceGeo Resource = "geo" - ResourcePasswords Resource = "passwords" - ResourcePeople Resource = "people" - ResourcePhotos Resource = "photos" - ResourcePlaces Resource = "places" - ResourceFeedback Resource = "feedback" + ResourceDefault Resource = "*" + ResourceConfig Resource = "config" + ResourceConfigOptions Resource = "config_options" + ResourceSettings Resource = "settings" + ResourceLogs Resource = "logs" + ResourceAccounts Resource = "accounts" + ResourceAlbums Resource = "albums" + ResourceCameras Resource = "cameras" + ResourceCategories Resource = "categories" + ResourceCountries Resource = "countries" + ResourceFiles Resource = "files" + ResourceFolders Resource = "folders" + ResourceLabels Resource = "labels" + ResourceLenses Resource = "lenses" + ResourceLinks Resource = "links" + ResourceGeo Resource = "geo" + ResourcePasswords Resource = "passwords" + ResourcePeople Resource = "people" + ResourcePhotos Resource = "photos" + ResourcePlaces Resource = "places" + ResourceFeedback Resource = "feedback" ) diff --git a/internal/api/config.go b/internal/api/config.go index d1f198afd..1cee735ce 100644 --- a/internal/api/config.go +++ b/internal/api/config.go @@ -39,7 +39,7 @@ func GetConfig(router *gin.RouterGroup) { // GET /api/v1/config/options func GetConfigOptions(router *gin.RouterGroup) { router.GET("/config/options", func(c *gin.Context) { - s := Auth(SessionID(c), acl.ResourceConfig, acl.ActionRead) + s := Auth(SessionID(c), acl.ResourceConfigOptions, acl.ActionRead) conf := service.Config() if s.Invalid() || conf.Public() || conf.DisableSettings() { @@ -54,7 +54,7 @@ func GetConfigOptions(router *gin.RouterGroup) { // POST /api/v1/config/options func SaveConfigOptions(router *gin.RouterGroup) { router.POST("/config/options", func(c *gin.Context) { - s := Auth(SessionID(c), acl.ResourceConfig, acl.ActionUpdate) + s := Auth(SessionID(c), acl.ResourceConfigOptions, acl.ActionUpdate) conf := service.Config() if s.Invalid() || conf.Public() || conf.DisableSettings() {