-
Notifications
You must be signed in to change notification settings - Fork 438
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
Ensures CSRF token is initialized prior to first modifying (non-GET
) request
#2886
Conversation
GET
) request
@atarix83 and @artlowel : This is the PR to fix the e2e test failures... if you have a chance to quickly glance at the code, I'd appreciate it. A few of the specs (unit tests) failed initially & I believe they should now succeed. Once all tests pass, I plan to merge this immediately as it corrects the behavior of CSRF token initialization, which results in the e2e tests now succeeding. That said, obviously we can do further fixes to this work if we notice anything later. Most of this code was actually written by @artlowel and I've simply updated it based on the backend changes in DSpace/DSpace#9321 & latest Angular code. |
…e". Fixes random failures starting e2e test backend via Docker
NOTE: we may wish to backport this PR to I've added this to the discussion for tomorrow's DevMtg: https://wiki.lyrasis.org/display/DSPACE/2024-04-04+DSpace+Developers+Meeting |
If I understand the issue correctly it affects the accuracy of statistics and thus would be a strong argument for backporting this PR to |
@alanorth : Correct. This would make statistics more accurate, which is the main reason I'd consider backporting this PR. Normally, we do not backport changes which modify the REST Contract (adding/removing/changing endpoints). But, in this case, the change is required to fix this particular bug. We'll be discussing this in upcoming Developer Meeting (in the next few weeks) to get more advice...but I'm currently leaning towards making an exception in this situation and backporting these changes to 7.x. |
Ported to 7.x in #3063 |
References
GET /api/security/csrf
endpoint added by Update DSpace with Jakarta EE Support (includes Tomcat 10+) DSpace#9321 and described by New/api/security/csrf
endpoint & updated CSRF docs RestContract#259Description
This PR ensures that the frontend will request a new CSRF token from the backend via the
GET /api/security/csrf
endpoint prior to the first modifying request (POST
,PUT
,DELETE
, etc), if the CSRF token has not yet been provided by the REST APIThis also fixes e2e test failures that are occurring in several PRs (#2871 and #2881) after the merger of DSpace/DSpace#9321. These e2e test failures only occurred on tests that required authentication. The cause of those failures were that the CSRF token was not yet initialized prior to Cypress attempting a login. This caused all logins via Cypress to fail with a CSRF token error.
Instructions for Reviewers
GET
instead ofPOST
and to fix minor lint/test failures.main
.