Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a00dc82

Browse filesBrowse files
[Security] Fix triggering session tracking from ContextListener
1 parent 9fd383a commit a00dc82
Copy full SHA for a00dc82

File tree

2 files changed

+5
-0
lines changed
Filter options

2 files changed

+5
-0
lines changed

‎src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/ContextListener.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public function onKernelResponse(ResponseEvent $event): void
164164
$session = $request->getSession();
165165
$sessionId = $session->getId();
166166
$usageIndexValue = $session instanceof Session ? $usageIndexReference = &$session->getUsageIndex() : null;
167+
$usageIndexReference = \PHP_INT_MIN;
167168
$token = $this->tokenStorage->getToken();
168169

169170
if (!$this->trustResolver->isAuthenticated($token)) {
@@ -178,6 +179,8 @@ public function onKernelResponse(ResponseEvent $event): void
178179

179180
if ($this->sessionTrackerEnabler && $session->getId() === $sessionId) {
180181
$usageIndexReference = $usageIndexValue;
182+
} else {
183+
$usageIndexReference = $usageIndexReference - \PHP_INT_MIN + $usageIndexValue;
181184
}
182185
}
183186

‎src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ public function testSessionIsNotReported()
323323

324324
$listener = new ContextListener($tokenStorage, [], 'context_key', null, null, null, $tokenStorage->getToken(...));
325325
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST));
326+
327+
$listener->onKernelResponse(new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST, new Response()));
326328
}
327329

328330
public function testOnKernelResponseRemoveListener()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.