Overview
Comment: | Garradin a désormais besoin d'un secret unique pour chaque installation |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
f2346dbb66c1fbf99ec0ea55226520b7 |
User & Date: | bohwaz on 2017-05-11 05:14:45 |
Other Links: | branch diff | manifest | tags |
Context
2017-05-11
| ||
06:11 | Utilisation de KD2\Security pour les tokens CSRF check-in: 6fa02716f8 user: bohwaz tags: dev | |
05:14 | Garradin a désormais besoin d'un secret unique pour chaque installation check-in: f2346dbb66 user: bohwaz tags: dev | |
2017-05-10
| ||
07:02 | Modernisation des fiches membres + amélioration UX avec des transitions check-in: 2bcf5d3c6a user: bohwaz tags: dev | |
Changes
Modified src/config.dist.php from [159ec20c1f] to [21bbfcec16].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * Pour configurer Garradin, copiez ce fichier en 'config.local.php' * puis décommentez et modifiez ce dont vous avez besoin. */ // Nécessaire pour situer les constantes dans le bon namespace namespace Garradin; /** * Se connecter automatiquement avec l'ID de membre indiqué * Exemple: LOCAL_LOGIN = 42 * * Défault : false (connexion automatique désactivée) */ const LOCAL_LOGIN = false; | > > > > > > > > > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | * Pour configurer Garradin, copiez ce fichier en 'config.local.php' * puis décommentez et modifiez ce dont vous avez besoin. */ // Nécessaire pour situer les constantes dans le bon namespace namespace Garradin; /** * Clé secrète, doit être unique à chaque instance de Garradin * * Ceci est utilisé afin de sécuriser l'envoi de formulaires * (protection anti-CSRF). * * Si aucune valeur n'est définie, Garradin ajoutera automatiquement * une valeur au hasard dans le fichier config.local.php. */ const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r'; /** * Se connecter automatiquement avec l'ID de membre indiqué * Exemple: LOCAL_LOGIN = 42 * * Défault : false (connexion automatique désactivée) */ const LOCAL_LOGIN = false; |
︙ | ︙ |
Modified src/include/init.php from [ba8a1afd8b] to [bfc98c00e2].
1 2 3 4 5 6 7 8 9 10 11 12 | <?php namespace Garradin; use KD2\ErrorManager; error_reporting(-1); /* * Version de Garradin */ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php namespace Garradin; use KD2\ErrorManager; use KD2\Security; error_reporting(-1); /* * Version de Garradin */ |
︙ | ︙ | |||
250 251 252 253 254 255 256 257 258 259 260 261 262 263 | exit; } // Message d'erreur simple pour les erreurs de l'utilisateur ErrorManager::setCustomExceptionHandler('\Garradin\UserException', '\Garradin\user_error'); ErrorManager::setCustomExceptionHandler('\KD2\MiniSkelMarkupException', '\Garradin\user_error'); /* * Vérifications pour enclencher le processus d'installation ou de mise à jour */ if (!defined('Garradin\INSTALL_PROCESS') && !defined('Garradin\UPGRADE_PROCESS')) { | > > > > > > > > > > > | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | exit; } // Message d'erreur simple pour les erreurs de l'utilisateur ErrorManager::setCustomExceptionHandler('\Garradin\UserException', '\Garradin\user_error'); ErrorManager::setCustomExceptionHandler('\KD2\MiniSkelMarkupException', '\Garradin\user_error'); // Clé secrète utilisée pour chiffrer les tokens CSRF etc. if (!defined('Garradin\SECRET_KEY')) { $key = base64_encode(Security::random_bytes(64)); Install::setLocalConfig('SECRET_KEY', $key); define('Garradin\SECRET_KEY', $key); } // Intégration du secret pour les tokens Security::tokenSetSecret(SECRET_KEY); /* * Vérifications pour enclencher le processus d'installation ou de mise à jour */ if (!defined('Garradin\INSTALL_PROCESS') && !defined('Garradin\UPGRADE_PROCESS')) { |
︙ | ︙ |
Modified src/include/lib/Garradin/Install.php from [323e87e4cd] to [2081420b50].
︙ | ︙ | |||
113 114 115 116 117 118 119 | 'libelle' => 'Premier exercice', 'debut' => date('Y-01-01'), 'fin' => date('Y-12-31') ]); return $config->save(); } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | 'libelle' => 'Premier exercice', 'debut' => date('Y-01-01'), 'fin' => date('Y-12-31') ]); return $config->save(); } static public function setLocalConfig($key, $value) { $path = ROOT . DIRECTORY_SEPARATOR . 'config.local.php'; $new_line = sprintf('const %s = %s;', $key, var_export($value, true)); if (file_exists($path)) { $config = file_get_contents($path); $pattern = sprintf('/^.*(?:const\s+%s|define\s*\(.*%1$s).*$/m', $key); $config = preg_replace($pattern, $new_line, $config, -1, $count); if (!$count) { $config = preg_replace('/\?>.*/s', '', $config); $config .= PHP_EOL . $new_line . PHP_EOL; } } else { $config = '<?php' . PHP_EOL . 'namespace Garradin;' . PHP_EOL . PHP_EOL . $new_line . PHP_EOL; } return file_put_contents($path, $config); } } |