8000 [Security] Fix forced redirection to referer if use_referer is enabled by pamil · Pull Request #23411 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Fix forced redirection to referer if use_referer is enabled #23411

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
Next Next commit
Provide real authentication success handler test cases with absolute …
…URLs
  • Loading branch information
pamil committed Jul 5, 2017
commit 1a5852f2c1623b3a51a45cc95dfff2f9ed32ec68
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,13 @@ public function testTargetPathIsPassedAsReferer()

$this->request->headers->expects($this->once())
->method('get')->with('Referer')
->will($this->returnValue('/dashboard'));
->will($this->returnValue('http://example.com/dashboard'));

$response = $this->expectRedirectResponse('/dashboard');
$this->httpUtils->expects($this->once())
->method('generateUri')->with($this->request, '/login')
->will($this->returnValue('http://example.com/login'));

$response = $this->expectRedirectResponse('http://example.com/dashboard');

$handler = new DefaultAuthenticationSuccessHandler($this->httpUtils, $options);
$result = $handler->onAuthenticationSuccess($this->request, $this->token);
Expand All @@ -145,11 +149,11 @@ public function testRefererHasToBeDifferentThanLoginUrl()

$this->request->headers->expects($this->any())
->method('get')->with('Referer')
->will($this->returnValue('/login'));
->will($this->returnValue('http://example.com/login'));

$this->httpUtils->expects($this->once())
->method('generateUri')->with($this->request, '/login')
->will($this->returnValue('/login'));
->will($this->returnValue('http://example.com/login'));

$response = $this->expectRedirectResponse('/');

Expand All @@ -165,11 +169,11 @@ public function testRefererWithoutParametersHasToBeDifferentThanLoginUrl()

$this->request->headers->expects($this->any())
->method('get')->with('Referer')
->will($this->returnValue('/subfolder/login?t=1&p=2'));
->will($this->returnValue('http://example.com/subfolder/login?t=1&p=2'));

$this->httpUtils->expects($this->once())
->method('generateUri')->with($this->request, '/login')
->will($this->returnValue('/subfolder/login'));
->will($this->returnValue('http://example.com/subfolder/login'));

$response = $this->expectRedirectResponse('/');

Expand Down
0