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

Allow CSRF to be disabled entirely #1656

Closed
matthewmcgarvey opened this issue Jan 29, 2022 Discussed in #1655 · 0 comments · Fixed by #1657
Closed

Allow CSRF to be disabled entirely #1656

matthewmcgarvey opened this issue Jan 29, 2022 Discussed in #1655 · 0 comments · Fixed by #1657

Comments

@matthewmcgarvey
Copy link
Member

Discussed in #1655

Originally posted by matthewmcgarvey January 26, 2022
Right now, flow specs work because they use Chrome (headlessly). In my work to add an in-memory version, we lose the ability to run javascript. That means we lose the ability for the javascript layer to add on csrf tokens to requests. This causes requests to fail.

In looking at how Capybara deals with this, I found that Rails disables CSRF protection in the test environment
https://github.com/rails/rails/blob/1438c0416fed98b20475b0cbe0c8e3965705cad0/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt#L34

I think we should do something similar. At least, we could add a setting to allow disabling it.

The setting would be used here:

private def protect_from_forgery
set_session_csrf_token
if request_does_not_require_protection? || valid_csrf_token?
continue
else
forbid_access_because_of_bad_token
end
end

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

Successfully merging a pull request may close this issue.

1 participant