API: Refactor ACL

This commit is contained in:
Michael Mayer 2020-12-19 01:54:48 +01:00
parent 651c4f12c1
commit 5f94f023ef
3 changed files with 24 additions and 24 deletions

View file

@ -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{

View file

@ -5,7 +5,7 @@ type Resource string
const (
ResourceDefault Resource = "*"
ResourceConfig Resource = "config"
ResourceOptions Resource = "options"
ResourceConfigOptions Resource = "config_options"
ResourceSettings Resource = "settings"
ResourceLogs Resource = "logs"
ResourceAccounts Resource = "accounts"

View file

@ -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() {