From d0e460cb406fe9ca5eab699ec3dad56324281997 Mon Sep 17 00:00:00 2001
From: Ahmed Awan <qe66653@umbc.edu>
Date: Tue, 21 May 2024 10:22:49 -0500
Subject: [PATCH] [24.0] Prevent anonymous users from running workflows

Fixes https://github.com/galaxyproject/galaxy/issues/18147
---
 lib/galaxy/webapps/galaxy/services/workflows.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/galaxy/webapps/galaxy/services/workflows.py b/lib/galaxy/webapps/galaxy/services/workflows.py
index 52e35d96c8fe..3cce4e906c6e 100644
--- a/lib/galaxy/webapps/galaxy/services/workflows.py
+++ b/lib/galaxy/webapps/galaxy/services/workflows.py
@@ -124,6 +124,8 @@ def invoke_workflow(
         workflow_id,
         payload: InvokeWorkflowPayload,
     ) -> Union[WorkflowInvocationResponse, List[WorkflowInvocationResponse]]:
+        if trans.anonymous:
+            raise exceptions.AuthenticationRequired("You need to be logged in to run workflows.")
         # Get workflow + accessibility check.
         by_stored_id = not payload.instance
         stored_workflow = self._workflows_manager.get_stored_accessible_workflow(trans, workflow_id, by_stored_id)