Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
EZP-25482: Fix exception with CSRF protection disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Feb 17, 2016
1 parent d4409aa commit 9a2db3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions ApplicationConfig/Providers/SessionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SessionInfo implements Provider

public function __construct(
SessionInterface $session,
CsrfTokenManagerInterface $csrfTokenManager,
CsrfTokenManagerInterface $csrfTokenManager = null,
$csrfTokenIntention,
RouterInterface $router
) {
Expand All @@ -46,11 +46,14 @@ public function getConfig()
$sessionInfo['isStarted'] = true;
$sessionInfo['name'] = $this->session->getName();
$sessionInfo['identifier'] = $this->session->getId();
$sessionInfo['csrfToken'] = $this->csrfTokenManager->getToken($this->csrfTokenIntention)->getValue();
$sessionInfo['href'] = $this->generateUrl(
'ezpublish_rest_deleteSession',
['sessionId' => $this->session->getId()]
);

if ($this->csrfTokenManager instanceof CsrfTokenManagerInterface) {
$sessionInfo['csrfToken'] = $this->csrfTokenManager->getToken($this->csrfTokenIntention)->getValue();
}
}

return $sessionInfo;
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ services:
class: %ezsystems.platformui.application_config.provider.session_info.class%
arguments:
- @session
- @security.csrf.token_manager
- @?security.csrf.token_manager
- %ezpublish_rest.csrf_token_intention%
- @router
tags:
Expand Down

0 comments on commit 9a2db3d

Please sign in to comment.