Skip to content

Commit 2d41858

Browse files
committed
fix: fill requester name/email from authenticated user, not form payload
Remove requester_name and requester_email from ToolRequestFormData and populate them server-side from trans.user to prevent spoofing. Update integration tests and regenerate API schema accordingly.
1 parent 252a8d2 commit 2d41858

3 files changed

Lines changed: 14 additions & 25 deletions

File tree

client/src/api/schema/schema.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23632,16 +23632,6 @@ export interface components {
2363223632
* @description The affiliation/lab of the requester.
2363323633
*/
2363423634
requester_affiliation?: string | null;
23635-
/**
23636-
* Requester email
23637-
* @description The email address of the requester for follow-up.
23638-
*/
23639-
requester_email?: string | null;
23640-
/**
23641-
* Requester name
23642-
* @description The name of the person requesting the tool.
23643-
*/
23644-
requester_name: string;
2364523635
/**
2364623636
* Scientific domain
2364723637
* @description The scientific domain for the requested tool.

lib/galaxy/webapps/galaxy/services/tool_request_form.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ class ToolRequestFormData(Model):
5353
test_data_available: Optional[bool] = Field(
5454
None, title="Test data available", description="Whether test data for this tool is available."
5555
)
56-
requester_name: str = Field(..., title="Requester name", description="The name of the person requesting the tool.")
57-
requester_email: Optional[str] = Field(
58-
None, title="Requester email", description="The email address of the requester for follow-up."
59-
)
6056
requester_affiliation: Optional[str] = Field(
6157
None, title="Requester affiliation", description="The affiliation/lab of the requester."
6258
)
@@ -98,7 +94,7 @@ def submit_tool_request(self, trans: ProvidesUserContext, payload: ToolRequestFo
9894
if not self.config.enable_tool_request_form:
9995
raise ServerNotConfiguredForRequest("The tool request form is not enabled in the configuration.")
10096

101-
if trans.anonymous:
97+
if trans.anonymous or trans.user is None:
10298
raise AuthenticationRequired("You must be logged in to submit a tool request.")
10399

104100
if not self.config.enable_notification_system:
@@ -116,8 +112,8 @@ def submit_tool_request(self, trans: ProvidesUserContext, payload: ToolRequestFo
116112
requested_version=payload.requested_version,
117113
conda_available=payload.conda_available,
118114
test_data_available=payload.test_data_available,
119-
requester_name=payload.requester_name,
120-
requester_email=payload.requester_email,
115+
requester_name=trans.user.username,
116+
requester_email=trans.user.email,
121117
requester_affiliation=payload.requester_affiliation,
122118
tool_ids=payload.tool_ids,
123119
workflow_name=payload.workflow_name,

test/integration/test_tool_request_form.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
"requested_version": "0.12.1",
1212
"conda_available": True,
1313
"test_data_available": True,
14-
"requester_name": "Dr. Smith",
15-
"requester_email": "smith@example.com",
1614
"requester_affiliation": "Example University",
1715
}
1816

@@ -63,9 +61,16 @@ def test_admin_receives_notification_after_submission(self):
6361
len(tool_request_notifications) >= 1
6462
), f"Expected at least one tool_request notification for admin, got: {notifications}"
6563

66-
notification = tool_request_notifications[0]
64+
sender_notifications = [
65+
n for n in tool_request_notifications if n["content"].get("requester_email") == user["email"]
66+
]
67+
assert (
68+
len(sender_notifications) >= 1
69+
), f"Expected notification from {user['email']}, got: {tool_request_notifications}"
70+
notification = sender_notifications[0]
6771
assert notification["content"]["tool_name"] == TOOL_REQUEST_PAYLOAD["tool_name"]
68-
assert notification["content"]["requester_name"] == TOOL_REQUEST_PAYLOAD["requester_name"]
72+
assert notification["content"]["requester_name"] == user["username"]
73+
assert notification["content"]["requester_email"] == user["email"]
6974
assert notification["content"]["description"] == TOOL_REQUEST_PAYLOAD["description"]
7075

7176
def test_missing_required_fields_returns_400(self):
@@ -74,19 +79,18 @@ def test_missing_required_fields_returns_400(self):
7479
with self._different_user(user["email"]):
7580
# Missing tool_name and description (both required)
7681
incomplete_payload = {
77-
"requester_name": "Dr. Smith",
82+
"requester_affiliation": "Example University",
7883
}
7984
response = self._post("tool_request_form", data=incomplete_payload, json=True)
8085
self._assert_status_code_is(response, 400)
8186

8287
def test_minimal_payload_succeeds(self):
83-
"""Only required fields should be enough to submit."""
88+
"""Only required fields (tool_name, description) should be enough to submit."""
8489
user = self._setup_user("tool_request_minimal@galaxy.test")
8590
with self._different_user(user["email"]):
8691
minimal_payload = {
8792
"tool_name": "Samtools",
8893
"description": "Tools for manipulating alignments in SAM format.",
89-
"requester_name": "Dr. Jones",
9094
}
9195
response = self._post("tool_request_form", data=minimal_payload, json=True)
9296
self._assert_status_code_is(response, 204)
@@ -101,7 +105,6 @@ def test_workflow_install_request_with_tool_ids(self):
101105
"but not installed: toolshed.g2.bx.psu.edu/repos/devteam/bwa/bwa/0.7.17, "
102106
"toolshed.g2.bx.psu.edu/repos/devteam/samtools/samtools/1.13."
103107
),
104-
"requester_name": "Dr. Smith",
105108
"tool_ids": [
106109
"toolshed.g2.bx.psu.edu/repos/devteam/bwa/bwa/0.7.17",
107110
"toolshed.g2.bx.psu.edu/repos/devteam/samtools/samtools/1.13",

0 commit comments

Comments
 (0)