Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the SECRET parameter in Symfony2 used for?

Tags:

yaml

symfony

can anyone tell me what is the SECRET parameter of parameters.yml in Symfony2?

like image 427
angrinessfap Avatar asked Jan 19 '16 21:01

angrinessfap


2 Answers

It is a security-related parameter used by the framework. From the doc :

This is a string that should be unique to your application and it's commonly used to add more entropy to security related operations. Its value should be a series of characters, numbers and symbols chosen randomly and the recommended length is around 32 characters.

Symfony2 uses this secret parameter for example to generate csrf tokens.

You can find more details, examples in the doc regarding the secret parameter.

like image 143
Fidan Hakaj Avatar answered Nov 20 '22 02:11

Fidan Hakaj


You just need to open console (on unix/mac/bsd) and run this command to get some random number with lenght 48:

$ sudo apt-get update && sudo apt-get install pwgen
$ pwgen 48 1 -By

which will produces something like this: bah7oTeixi~to.aFoh~quoh~Yee3eequomae7aib`ie#hoo7

or you just could use your dev/urandom for that: $ cat /dev/urandom | strings --bytes 1 | tr -d '\n\t [](){}"' | head --bytes 48

after that you could set it as value of secret parameter instead of ThisTokenIsNotSecretChangeIt

I also do not recommend to use http://nux.net/secret for that because of limited length and limited secret number's alphabet (a-f0-9+)

like image 11
alexglue Avatar answered Nov 20 '22 02:11

alexglue