-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[24.0] Fix authentication error for anonymous users querying jobs #18333
[24.0] Fix authentication error for anonymous users querying jobs #18333
Conversation
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: lib/galaxy/managers/jobs.py
📄 File: lib/galaxy/webapps/galaxy/services/jobs.py (Click to Expand)
Did you find this useful? React with a 👍 or 👎 |
lib/galaxy/managers/jobs.py
Outdated
@@ -111,6 +112,8 @@ def index_query(self, trans, payload: JobIndexQueryPayload) -> sqlalchemy.engine | |||
Otherwise this will only return the user's jobs or all jobs if the requesting | |||
user is acting as an admin. | |||
""" | |||
if trans.user is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead query the jobs using the session id or current session history ? I think there's no reason anon user can't see their jobs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I forgot there was a way to differentiate jobs from other anonymous users. I'll give it a try 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to write an API or selenium test but I couldn't figure out how to use the session. I manually tested and seems to work though.
3370b23
to
2e91272
Compare
Co-authored-by: Nicola Soranzo <[email protected]>
if trans.galaxy_session and trans.galaxy_session.current_history_id: | ||
history_id = trans.galaxy_session.current_history_id | ||
else: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should raise an AuthenticationRequired
exception here instead, so the error is not hidden from the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an error, if a session doesn't have a history it also doesn't have any jobs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But None is returned also is trans.galaxy_session
is None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is fine and not a error ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could as well query some public thing, like jobs belonging to a history, raising an exception here feels very unpredictable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I don't understand the changes in lines 131-133 above: if we want a session-less user to be able to view public history jobs, we should overwrite history_id
only when it's None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good point, we might want to instead filter on the job itself using the session id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If history_id
is passed in the API payload, the job's history accessibility is checked on the jobs returned by this method at
if check_security_of_jobs and not security_check(trans, job.history, check_accessible=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch! I'll follow up with the proposed change 👍
Fixes #18331
I added the check at the API level (to fail fast) and at the manager level in case it gets called from somewhere else.
How to test the changes?
License