Created
September 9, 2014 16:22
-
-
Save forced-request/a29212b17d12bf57a88f to your computer and use it in GitHub Desktop.
CSRF Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
# Overload handle_unverified_request to ensure that | |
# exception is raised each time a request does not | |
# pass validation. | |
def handle_unverified_request | |
raise(ActionController::InvalidAuthenticityToken) | |
end | |
end | |
class AccountController < ApplicationController | |
def transfer_funds | |
Funds.transfer(params[:source_account], params[:destination_account], params[:quantity]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment