-
Notifications
You must be signed in to change notification settings - Fork 31
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
Allow a non-public user to get their event context #422
Conversation
I tried this on merge-ci... but this just returned me the login page html:
According to snoopycrimecop@02e18f3 and redeployed with https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-web/ the PR should be there, but is there any way to check? |
|
Oops - my mistake. But I'm afraid that using the correct URL didn't get me there either:
|
I got the same output while testing earlier. I forgot to copy it |
With this morning build
|
latest-ci (Expected)
|
merge-ci
|
Some integration test failures today with login tests: https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-test-integration/1306/ |
6e2a45b should resolve the test failures by ensuring that the logic does not run when any form fields are provided. I'm pretty sure what was happening is that the tests were not logging out between requests so you were getting the current event context when providing "incorrect" fields. |
Thanks for that Chris, and nice that it doesn't need to update tests (no change in functionality). |
Definitely. I would have done it right away but didn't want to create omero-py vs. openmicroscopy merge order issues for everyone since the integration tests are not in this repository. Would you like them done before or after this PR is merged? |
I don't think that integration tests are a blocker for this PR. Whenever works really. |
aacb392
to
c61e6aa
Compare
c61e6aa should resolve the last test failure. It will be very tricky to integration test all these conditions with the different ways to provide CSRF tokens and the login/logout semantics of the current test suite here but I'll try once things are green with what we have now. |
Build #1310 (Dec 13, 2022 1:13:47 AM) https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-test-integration/1310/
|
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.
$.post("https://merge-ci.openmicroscopy.org/web/api/v0/login/", (rsp)=>console.log(rsp));
is still working for me on merge-ci.
Tests passing.
👍
It's very useful for a non-public user to be able to retrieve the current event context at any time rather than just at login; particularly so for scenarios where API access is being done by OMERO session key. This is especially important when using OMERO session creation strategies such as single sign on (SSO) or other login view plugin. Otherwise, retrieving the current OMERO session key, knowing one's current groups, etc. is currently impossible from OMERO.web APIs.
The requirement for
POST
, where the request is subject to all the standard CSRF protection criteria enforced by Django, is to prevent session hijacking via clickjacking or similar attacks.To test, simply open your browser developer tools to the network tab and log in to OMERO.web. Really any request will do but the initial one to
/webclient/
is usually the easiest to handle. You will want to copy the entirety of theCookie:
header, for example:You can then craft a suitable request to
/api/v0/login/
viacurl
to ensure the event context can be retrieved. For example:Where the value for the
Cookie:
is what you copied from your network tab and the value ofcsrfmiddlewaretoken
is the same as thecsrftoken
from your cookie.Referrer:
is essential if you are using HTTPS; the same URL you are sending thePOST
to.The response should look something like:
You can then destroy your session via the
omero-py
CLI:and ensure the regular behaviour is present by re-executing your
curl
crafted as above where you will get a response like: