ソースを参照

bugfix: System users can now be used in ACLs (#396)

James Read 1 年間 前
コミット
3f1dbf1130

+ 4 - 6
internal/oncalendarfile/calendar.go

@@ -107,12 +107,10 @@ func exec(instant time.Time, action *config.Action, cfg *config.Config, ex *exec
 	}).Infof("Executing action from calendar")
 
 	req := &executor.ExecutionRequest{
-		Action: action,
-		Cfg:    cfg,
-		Tags:   []string{"calendar"},
-		AuthenticatedUser: &acl.AuthenticatedUser{
-			Username: "calendar",
-		},
+		Action:            action,
+		Cfg:               cfg,
+		Tags:              []string{"calendar"},
+		AuthenticatedUser: acl.UserFromSystem(cfg, "calendar"),
 	}
 
 	ex.ExecRequest(req)

+ 4 - 6
internal/oncron/cron.go

@@ -34,12 +34,10 @@ func scheduleAction(cfg *config.Config, scheduler *cron.Cron, cronline string, e
 
 	_, err := scheduler.AddFunc(cronline, func() {
 		req := &executor.ExecutionRequest{
-			ActionTitle: action.Title,
-			Cfg:         cfg,
-			Tags:        []string{"cron"},
-			AuthenticatedUser: &acl.AuthenticatedUser{
-				Username: "cron",
-			},
+			ActionTitle:       action.Title,
+			Cfg:               cfg,
+			Tags:              []string{"cron"},
+			AuthenticatedUser: acl.UserFromSystem(cfg, "cron"),
 		}
 
 		ex.ExecRequest(req)

+ 5 - 7
internal/onfileindir/fileindir.go

@@ -44,13 +44,11 @@ func scheduleExec(action *config.Action, cfg *config.Config, ex *executor.Execut
 	fmt.Printf("%+v", args)
 
 	req := &executor.ExecutionRequest{
-		ActionTitle: action.Title,
-		Cfg:         cfg,
-		Tags:        []string{"fileindir"},
-		Arguments:   args,
-		AuthenticatedUser: &acl.AuthenticatedUser{
-			Username: "fileindir",
-		},
+		ActionTitle:       action.Title,
+		Cfg:               cfg,
+		Tags:              []string{"fileindir"},
+		Arguments:         args,
+		AuthenticatedUser: acl.UserFromSystem(cfg, "fileindir"),
 	}
 
 	ex.ExecRequest(req)

+ 1 - 3
internal/onstartup/startup.go

@@ -8,9 +8,7 @@ import (
 )
 
 func Execute(cfg *config.Config, ex *executor.Executor) {
-	user := &acl.AuthenticatedUser{
-		Username: "startup-user",
-	}
+	user := acl.UserFromSystem(cfg, "startup-user")
 
 	for _, action := range cfg.Actions {
 		if action.ExecOnStartup {