Skip to content

Commit a55b61c

Browse files
authored
Merge pull request #20524 from bernt-matthias/users
[24.2] Do not expose user info to non authenticated users
2 parents 6f182d7 + fdf931b commit a55b61c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/galaxy/webapps/galaxy/services/users.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ def get_index(
202202
f_name: Optional[str],
203203
f_any: Optional[str],
204204
) -> List[MaybeLimitedUserModel]:
205+
# never give any info to non-authenticated users
206+
if not trans.user:
207+
raise glx_exceptions.AuthenticationRequired("Only registered users can view the list of users")
208+
205209
# check for early return conditions
206210
if deleted:
207211
if not trans.user_is_admin:
@@ -216,10 +220,7 @@ def get_index(
216220
and not trans.app.config.expose_user_name
217221
and not trans.app.config.expose_user_email
218222
):
219-
if trans.user:
220-
return [UserModel(**trans.user.to_dict())]
221-
else:
222-
return []
223+
return [UserModel(**trans.user.to_dict())]
223224

224225
users = get_users_for_index(
225226
trans.sa_session,

lib/galaxy_test/api/test_users.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ def test_index(self):
4747
all_deleted_users = all_deleted_users_response_2.json()
4848
assert len([u for u in all_deleted_users if u["email"] == TEST_USER_EMAIL_INDEX_DELETED]) == 1
4949

50+
def test_index_anon(self):
51+
with self._different_user(anon=True):
52+
all_users_response = self._get("users")
53+
self._assert_status_code_is(all_users_response, 403)
54+
5055
@requires_new_user
5156
def test_index_only_self_for_nonadmins(self):
5257
self._setup_user(TEST_USER_EMAIL)

0 commit comments

Comments
 (0)