chore: enable csrf token to be read from request headers #2586
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces to provide a csrf token via request headers. The main reason for this is that currently we are only checking csrf token on rpc form requests by adding a hidden input field to the form which contains the token.
From my perspective this is not optimal. We also load our addons via a rpc route but we do not submit a form therefore the loading of addons results in purple error messages saying the csrf token is missing. Also I find this a more convenient way to handle the csrf token.
In a coming PR all occurrences of hidden input fields can be removed since the changes of this PR will parse the headers for a X-Csrf-Token field which contains the token and can be validated within the CsrfSubscriber class.
How to review/test
Linked PRs (optional)
demos-europe/demosplan-ui#714
Important
Before removing the hidden input field throughout dplan the demosplan-ui PR needs to be merged first (however merging this PR will not break things since both cases can be handled now when receiving rpc requests)