Merge pull request #2 from alromh87/master
Fix Cross Site Request Forgery on theme selection by using token
This commit is contained in:
commit
b038016daf
2 changed files with 22 additions and 7 deletions
|
@ -21,10 +21,25 @@ checkRole(array('admin'));
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Main after POST
|
// Main after POST
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
$themeDirectory = $layout['parameters'];
|
$token = "";
|
||||||
|
$parameters = explode("/", $layout['parameters']);
|
||||||
|
if(count($parameters)==2) {
|
||||||
|
$themeDirectory = $parameters[0];
|
||||||
|
|
||||||
// Activate theme
|
// Verify CSRF Token
|
||||||
activateTheme($themeDirectory);
|
$token = Sanitize::html($parameters[1]);
|
||||||
|
if ($security->validateTokenCSRF($token)) {
|
||||||
|
// Activate theme
|
||||||
|
activateTheme($themeDirectory);
|
||||||
|
|
||||||
|
// Redirect
|
||||||
|
Redirect::page('themes');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::set(__FILE__.LOG_SEP.'Error occurred when trying to validate the tokenCSRF.', ALERT_STATUS_FAIL);
|
||||||
|
Log::set(__FILE__.LOG_SEP.'Token in install theme ['.$token.']', ALERT_STATUS_FAIL);
|
||||||
|
|
||||||
|
Session::destroy();
|
||||||
|
Redirect::page('login');
|
||||||
|
|
||||||
// Redirect
|
|
||||||
Redirect::page('themes');
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ foreach ($themes as $theme) {
|
||||||
';
|
';
|
||||||
|
|
||||||
if ($theme['dirname']!=$site->theme()) {
|
if ($theme['dirname']!=$site->theme()) {
|
||||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>';
|
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'/'.$security->getTokenCSRF().'">'.$L->g('Activate').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
@ -50,4 +50,4 @@ foreach ($themes as $theme) {
|
||||||
echo '
|
echo '
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
';
|
';
|
||||||
|
|
Loading…
Add table
Reference in a new issue