Commit 4c201202 authored by Antoine Catton's avatar Antoine Catton

Generate secret key for php application.

parent 5d3204e4
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
import shutil import shutil
import os import os
import signal import signal
from binascii import b2a_uu as uuencode
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
...@@ -72,12 +73,17 @@ class Recipe(GenericBaseRecipe): ...@@ -72,12 +73,17 @@ class Recipe(GenericBaseRecipe):
) )
path_list.append(wrapper) path_list.append(wrapper)
mysql_conf = dict(mysql_database=self.options['mysql-database'], secret_key = uuencode(os.urandom(45)).strip()
mysql_user=self.options['mysql-username'], # Remove unsafe characters
mysql_password=self.options['mysql-password'], secret_key = secret_key.translate(None, '"\'')
mysql_host='%s:%s' % (self.options['mysql-host'],
self.options['mysql-port']), application_conf = dict(mysql_database=self.options['mysql-database'],
) mysql_user=self.options['mysql-username'],
mysql_password=self.options['mysql-password'],
mysql_host='%s:%s' % (self.options['mysql-host'],
self.options['mysql-port']),
secret_key=secret_key,
)
directory, file_ = os.path.split(self.options['configuration']) directory, file_ = os.path.split(self.options['configuration'])
...@@ -91,7 +97,7 @@ class Recipe(GenericBaseRecipe): ...@@ -91,7 +97,7 @@ class Recipe(GenericBaseRecipe):
destination = os.path.join(path, file_) destination = os.path.join(path, file_)
config = self.createFile(destination, config = self.createFile(destination,
self.substituteTemplate(self.options['template'], mysql_conf)) self.substituteTemplate(self.options['template'], application_conf))
path_list.append(config) path_list.append(config)
if os.path.exists(self.options['pid-file']): if os.path.exists(self.options['pid-file']):
......
...@@ -21,7 +21,7 @@ location = ${buildout:parts-directory}/${:_buildout_section_name_} ...@@ -21,7 +21,7 @@ location = ${buildout:parts-directory}/${:_buildout_section_name_}
[application-configuration] [application-configuration]
location = wp-config.php location = wp-config.php
md5sum = 608dd9003a8edeb59c3aabc6cf43bbf9 md5sum = 3859841a4ad6ed23744d6bc5a01321e0
[versions] [versions]
#slapos.cookbook = 0.12 #slapos.cookbook = 0.12
......
...@@ -42,14 +42,14 @@ define('DB_COLLATE', ''); ...@@ -42,14 +42,14 @@ define('DB_COLLATE', '');
* *
* @since 2.6.0 * @since 2.6.0
*/ */
define('AUTH_KEY', 'put your unique phrase here'); define('AUTH_KEY', '%(secret_key)s');
define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', '%(secret_key)s');
define('LOGGED_IN_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', '%(secret_key)s');
define('NONCE_KEY', 'put your unique phrase here'); define('NONCE_KEY', '%(secret_key)s');
define('AUTH_SALT', 'put your unique phrase here'); define('AUTH_SALT', '%(secret_key)s');
define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', '%(secret_key)s');
define('LOGGED_IN_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', '%(secret_key)s');
define('NONCE_SALT', 'put your unique phrase here'); define('NONCE_SALT', '%(secret_key)s');
/**#@-*/ /**#@-*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment