Skip to content
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

Enhance CSRF handling of AJAX endpoints #18723

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cedric-anne
Copy link
Member

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.

Description

GLPI has currently a distinct CSRF check logic for AJAX endpoint. Indeed, for these specific endpoints, a CSRF token can be consumed multiple times, see 93750ea

The propose change permits to consider that a request is an AJAX request when the X-Requested-With: XMLHttpRequest is used (it is commonly used as a flag to mark AJAX requests by the popular JS frameworks), instead of checking tha the request is made on a /ajax/xxx path.

The idea is to permit to use any URL pattern for AJAX endpoints.

@trasher
Copy link
Contributor

trasher commented Jan 14, 2025

Web tests are failing

@cedric-anne
Copy link
Member Author

Web tests are failing

Yes, I have some more changes to do. I am putting this PR back in draft for now.

@cedric-anne cedric-anne marked this pull request as draft January 15, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants