Skip to content

Commit

Permalink
Merge branch 'release_24.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Jun 11, 2024
2 parents ed117ef + 13de716 commit 114ab57
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,4 @@ def file_sources(self):

@property
def anonymous(self) -> bool:
return bool(self._kwd.get("username"))
return not bool(self._kwd.get("username"))
24 changes: 10 additions & 14 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
cast,
Dict,
List,
Optional,
)

import sqlalchemy
Expand All @@ -33,6 +32,7 @@
ItemAccessibilityException,
ObjectNotFound,
RequestParameterInvalidException,
RequestParameterMissingException,
)
from galaxy.job_metrics import (
RawMetric,
Expand Down Expand Up @@ -108,9 +108,7 @@ def __init__(self, app: StructuredApp):
self.app = app
self.dataset_manager = DatasetManager(app)

def index_query(
self, trans: ProvidesUserContext, payload: JobIndexQueryPayload
) -> Optional[sqlalchemy.engine.ScalarResult]:
def index_query(self, trans: ProvidesUserContext, payload: JobIndexQueryPayload) -> sqlalchemy.engine.ScalarResult:
"""The caller is responsible for security checks on the resulting job if
history_id, invocation_id, or implicit_collection_jobs_id is set.
Otherwise this will only return the user's jobs or all jobs if the requesting
Expand All @@ -126,13 +124,6 @@ def index_query(
search = payload.search
order_by = payload.order_by

if trans.user is None:
# If the user is anonymous we can only return jobs for the current session history
if trans.galaxy_session and trans.galaxy_session.current_history_id:
history_id = trans.galaxy_session.current_history_id
else:
return None

def build_and_apply_filters(stmt, objects, filter_func):
if objects is not None:
if isinstance(objects, (str, date, datetime)):
Expand Down Expand Up @@ -219,9 +210,14 @@ def add_search_criteria(stmt):
if user_details:
stmt = stmt.outerjoin(Job.user)
else:
if history_id is None and invocation_id is None and implicit_collection_jobs_id is None and trans.user:
stmt = stmt.where(Job.user_id == trans.user.id)
# caller better check security
if history_id is None and invocation_id is None and implicit_collection_jobs_id is None:
# If we're not filtering on history, invocation or collection we filter the jobs owned by the current user
if trans.user:
stmt = stmt.where(Job.user_id == trans.user.id)
elif trans.galaxy_session:
stmt = stmt.where(Job.session_id == trans.galaxy_session.id)
else:
raise RequestParameterMissingException("A session is required to list jobs for anonymous users")

stmt = build_and_apply_filters(stmt, payload.states, lambda s: model.Job.state == s)
stmt = build_and_apply_filters(stmt, payload.tool_ids, lambda t: model.Job.tool_id == t)
Expand Down
2 changes: 0 additions & 2 deletions lib/galaxy/webapps/galaxy/services/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ def index(
)
jobs = self.job_manager.index_query(trans, payload)
out: List[Dict[str, Any]] = []
if jobs is None:
return out
for job in jobs.yield_per(model.YIELD_PER_ROWS):
# TODO: optimize if this crucial
if check_security_of_jobs and not security_check(trans, job.history, check_accessible=True):
Expand Down

0 comments on commit 114ab57

Please sign in to comment.