From 853f4e5d8716823949e7d70eb46c5f37ead03113 Mon Sep 17 00:00:00 2001 From: Frikky Date: Wed, 17 Jan 2024 13:16:34 +0100 Subject: [PATCH 1/2] Fixed further small issues for skipped actions --- shared.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shared.go b/shared.go index c202bbe..4bc012d 100755 --- a/shared.go +++ b/shared.go @@ -11002,7 +11002,7 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut } } - log.Printf("\n\n\n[WARNING][%s] Found that %s (%s) should be skipped? Should check if it has more parents. If not, send in a skip\n\n\n", workflowExecution.ExecutionId, foundAction.Label, foundAction.ID) + log.Printf("[DEBUG][%s] Found that %s (%s) should be skipped? Should check if it has more parents. If not, send in a skip", workflowExecution.ExecutionId, foundAction.Label, foundAction.AppName) foundCount := 0 skippedBranches := []string{} @@ -11028,7 +11028,7 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut skippedCount := len(skippedBranches) - log.Printf("\n\n[DEBUG][%s] Found %d branch(es) for %s. %d skipped. If equal, make the node skipped. SKIPPED: %s\n\n", workflowExecution.ExecutionId, foundCount, foundAction.Label, skippedCount, skippedBranches) + log.Printf("[DEBUG][%s] Found %d branch(es) for %s. %d skipped. If equal, make the node skipped. SKIPPED: %s", workflowExecution.ExecutionId, foundCount, foundAction.Label, skippedCount, skippedBranches) if foundCount == skippedCount { found := false for _, res := range workflowExecution.Results { @@ -11072,6 +11072,7 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut streamUrl = fmt.Sprintf("http://%s:33333/api/v1/streams", os.Getenv("WORKER_HOSTNAME")) } + log.Printf("[DEBUG] OPTIMIZED: %s, PORT: %s", os.Getenv("SHUFFLE_OPTIMIZED"), os.Getenv("WORKER_PORT")) if os.Getenv("SHUFFLE_OPTIMIZED") == "true" && len(os.Getenv("WORKER_PORT")) > 0 { streamUrl = fmt.Sprintf("http://localhost:%s/api/v1/streams", os.Getenv("WORKER_PORT")) } else if os.Getenv("SHUFFLE_SWARM_CONFIG") == "run" && (project.Environment == "" || project.Environment == "worker") { @@ -11087,7 +11088,8 @@ func ParsedExecutionResult(ctx context.Context, workflowExecution WorkflowExecut } } - log.Printf("[DEBUG] Sending skip for action %s (%s) to URL %s", streamUrl) + log.Printf("[DEBUG] Sending skip for action %s (%s) to URL %s", foundAction.Label, foundAction.AppName, streamUrl) + req, err := http.NewRequest( "POST", streamUrl, From 7827568a9e94d8a6f7af50ef0cf78554d179f052 Mon Sep 17 00:00:00 2001 From: Frikky Date: Wed, 17 Jan 2024 22:20:34 +0100 Subject: [PATCH 2/2] Made control of users better for admins of parent orgs --- shared.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/shared.go b/shared.go index 4bc012d..e64bcbb 100755 --- a/shared.go +++ b/shared.go @@ -3583,10 +3583,10 @@ func HandleUpdateUser(resp http.ResponseWriter, request *http.Request) { isSelf = CheckCreatorSelfPermission(ctx, userInfo, *foundUser, &AlgoliaSearchCreator{ObjectID: foundUser.Id, IsOrg: true,}) } - if !isSelf || len(foundUser.Id) != 32 { - log.Printf("[AUDIT] User %s is admin, but can't edit users outside their own org (%s).", userInfo.Id, foundUser.Id) - resp.WriteHeader(401) - resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't change users outside your org."}`))) + if (!isSelf || len(foundUser.Id) != 32) && !userInfo.SupportAccess { + log.Printf("[AUDIT] User %s (%s) is admin, but can't edit users outside their own org (%s).", userInfo.Username, userInfo.Id, foundUser.Id) + resp.WriteHeader(400) + resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "You don't have access to modify this user. Contact support@shuffler.io if you think this is wrong."}`))) return } } @@ -6375,7 +6375,7 @@ func HandlePasswordChange(resp http.ResponseWriter, request *http.Request) { if !orgFound { log.Printf("[AUDIT] User %s (%s) is admin, but can't change user's (%s) password outside their own org.", userInfo.Username, userInfo.Id, foundUser.Username) resp.WriteHeader(401) - resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't change users outside your org."}`))) + resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't change users outside your org (2)."}`))) return } } else { @@ -6785,12 +6785,10 @@ func DeleteUser(resp http.ResponseWriter, request *http.Request) { } } - if !orgFound { - - - log.Printf("[AUDIT] User %s is admin, but can't delete users outside their own org.", userInfo.Id) + if !orgFound && !userInfo.SupportAccess { + log.Printf("[AUDIT] User %s (%s) is admin, but can't delete users outside their own org.", userInfo.Username, userInfo.Id) resp.WriteHeader(401) - resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't change users outside your org."}`))) + resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Can't change users outside your org (1)."}`))) return } @@ -6856,7 +6854,7 @@ func DeleteUser(resp http.ResponseWriter, request *http.Request) { return } - log.Printf("[INFO] Successfully removed %s from org %s", foundUser.Username, userInfo.ActiveOrg.Id) + log.Printf("[AUDIT] User %s (%s) successfully removed %s from org %s", userInfo.Username, userInfo.Id, foundUser.Username, userInfo.ActiveOrg.Id) resp.WriteHeader(200) resp.Write([]byte(`{"success": true}`))