Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we generate a XSRF token for events #2903

Open
wants to merge 1 commit into
base: 2.7.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions symphony/lib/toolkit/class.frontendpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,20 @@ private function processEvents($events, XMLElement &$wrapper)

foreach ($events as $handle) {
$pool[$handle] = EventManager::create($handle, array('env' => $this->_env, 'param' => $this->_param));
// Make sure that filters requiring XSRF token to work are getting a valid XSRF token.
// We do not always create it, because that would create useless sessions
if (
Symphony::isXSRFEnabled() && !XSRF::getSessionToken() &&
isset($pool[$handle]->eParamFILTERS) &&
is_array($pool[$handle]->eParamFILTERS)
) {
$xsrfFilters = array_filter($pool[$handle]->eParamFILTERS, function ($filter) {
return strpos($filter, 'xsrf') !== false;
});
if (!empty($xsrfFilters)) {
$this->_param['cookie-xsrf-token'] = XSRF::getToken();
}
}
}

uasort($pool, array($this, '__findEventOrder'));
Expand Down