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

Extend javascript emulation to handle rails CSRF protection #164

Merged
merged 2 commits into from
Sep 11, 2011

Conversation

JonathonMA
Copy link
Contributor

When rails detects a non GET request that doesn't send the authentication_token parameter, it resets the session.

The current implementation of javascript emulation only changes the method to POST and also sends in the emulated _method parameter, but it does not emulate sending the CSRF token and so will break any behaviour that relies on the session being maintained (e.g. authentication).

This extends the javascript emulation to also parse the csrf_param and csrf_token from the meta tags and send them along with the _method parameter.

  * rails CSRF protection wipes the session when it triggers
  * to trigger it in cucumber we first enable it in test mode
    by changing config/environments/test.rb
  * we also need to make correct behaviour rely on the session being
    present, so we set up a before_filter
  * we need an action that configures the setup correctly:
    session/establish
@aslakhellesoy aslakhellesoy merged commit 6f9c533 into cucumber:master Sep 11, 2011
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 this pull request may close these issues.

2 participants