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

Include CSRF <meta> elements in frame layout #697

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Oct 29, 2024

Closes #669

If a response to a request with the Turbo-Frame: header does not include the <meta> elements in the <html> document, it's likely that the browser will remove any <meta> element present after handling navigating the <turbo-frame> that originated the request.

In support of testing this behavior, this commit enables CSRF protection in the test suite.

@seanpdoyle
Copy link
Contributor Author

This is a more conservative, less disruptive alternative to #534.

While this might resolve any CSRF-related inconsistencies in the <head>, it is still an incomplete solution. For example, it does not include CSP <meta> elements, PWA <meta> elements, or any other <head> elements that new Rails applications are generated with by default.

While #534 might feel too ambitious of a proposal, it circumvents this entire class of issue, and removes any burden of responsibility to decide which <head> elements are worth including by default.

@ramhoj
Copy link
Contributor

ramhoj commented Oct 29, 2024

Regarding the failing Rails 7.1 tests, I had the same issue in another branch and submitted #696 to address them.

Closes [hotwired#669][]

If a response to a request with the `Turbo-Frame:` header does not
include the `<meta>` elements in the `<html>` document, it's likely that
the browser will remove any `<meta>` element present after handling
navigating the `<turbo-frame>` that originated the request.

In support of testing this behavior, this commit enables CSRF protection
in the test suite.
@seanpdoyle
Copy link
Contributor Author

@jorgemanrubia @brunoprietog are either of you experiencing this issue in your applications?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Turbo frame request is removing the csrf meta tag
2 participants