Skip to content

Conversation

@PaulL1
Copy link
Contributor

@PaulL1 PaulL1 commented Apr 17, 2014

I think the changes to the default behaviour mean that rails will throw an exception when an invalid authenticity token is found. The previous proposed code of calling super then sign_out meant that sign_out was never reached - the exception handler never returned.

I think the best approach now is to catch the exception, although I'm not 100% certain on that. I've handled this by proposing the documentation change, rather than just asking the question - feel free to reject if this isn't the right solution.

I think the changes to the default behaviour mean that rails will throw an exception when an invalid authenticity token is found.  The previous proposed code of calling super then sign_out meant that sign_out was never reached - the exception handler never returned.

I think the best approach now is to catch the exception, although I'm not 100% certain on that.
@rafaelfranca
Copy link
Member

Guides should mention what is correct with the default behavior. If it is exception we should change it.

@rafaelfranca
Copy link
Member

But in this case the code before it is not using the exception option. I think we should change the guides to use the new Rails default.

Extend previous changes, include the default line from the application controller that new rails applications are created with: 
  protect_from_forgery with: :exception

Minor wording changes to align.
@PaulL1
Copy link
Contributor Author

PaulL1 commented Apr 17, 2014

Agree. Extended to align with your suggestion.

@PaulL1
Copy link
Contributor Author

PaulL1 commented Apr 17, 2014

On a related matter, the security guide makes no mention of setting encrypted_cookie_salt or encrypted_signed_cookie_salt to values other than the default. It seems likely that this would be a good idea (there seems little point having a salt with a known value), but I haven't seen anything anywhere on the web that recommends it. Is this an oversight?

@rafaelfranca
Copy link
Member

salt can be a known value without problem. But if you want to have be extra cautious you can set. I think we don't need to recommend changing it on the guide.

rafaelfranca added a commit that referenced this pull request Apr 17, 2014
CSRF protection should rescue exception not extend
@rafaelfranca rafaelfranca merged commit a3fd6e7 into rails:master Apr 17, 2014
@PaulL1 PaulL1 deleted the patch-1 branch April 17, 2014 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants