Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails secret token

Tags:

I'm quite confused what is secret_token used for in Rails. Can anyone explain what it is used for? Is it OK to put this token in a public source repository and use it in production, or I should change it before deploying my app to prevent some kinds of attacks?

like image 651
Marek Sapota Avatar asked Nov 22 '10 01:11

Marek Sapota


1 Answers

Answering my own question - secret_token is used to prevent cookie tampering in Rails. Every cookie has a checksum saved with it, so users won't modify cookie contents (and change saved user id to steal someone's account, for example). The checksum is based on cookie contents and secret_token, so if you are using cookie based sessions you should always make sure your secret_token is really secret, otherwise you can't trust that anything you put into session came back unchanged.

like image 193
Marek Sapota Avatar answered Nov 20 '22 16:11

Marek Sapota