Skip to content

Commit e43cd20

Browse files
committed
[Security] Fix http retry authentication entry point
1 parent cb3ad8b commit e43cd20

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function start(Request $request, AuthenticationException $authException =
4040
$scheme = $request->isSecure() ? 'http' : 'https';
4141
if ('http' === $scheme && 80 != $this->httpPort) {
4242
$port = ':'.$this->httpPort;
43-
} elseif ('https' === $scheme && 443 != $this->httpPort) {
43+
} elseif ('https' === $scheme && 443 != $this->httpsPort) {
4444
$port = ':'.$this->httpsPort;
4545
} else {
4646
$port = '';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace Symfony\Tests\Component\Security\Http\EntryPoint;
4+
5+
use Symfony\Component\Security\Http\EntryPoint\RetryAuthenticationEntryPoint;
6+
use Symfony\Component\HttpFoundation\Request;
7+
8+
class RetryAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @dataProvider dataForStart
12+
*/
13+
public function testStart($httpPort, $httpsPort, $request, $expectedUrl)
14+
{
15+
$entryPoint = new RetryAuthenticationEntryPoint($httpPort, $httpsPort);
16+
$response = $entryPoint->start($request);
17+
18+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
19+
$this->assertEquals($expectedUrl, $response->headers->get('Location'));
20+
}
21+
22+
public function dataForStart()
23+
{
24+
return array(
25+
array(
26+
80,
27+
443,
28+
Request::create('http://localhost/foo/bar?baz=bat'),
29+
'https://localhost/foo/bar?baz=bat'
30+
),
31+
array(
32+
80,
33+
443,
34+
Request::create('https://localhost/foo/bar?baz=bat'),
35+
'http://localhost/foo/bar?baz=bat'
36+
),
37+
array(
38+
80,
39+
123,
40+
Request::create('http://localhost/foo/bar?baz=bat'),
41+
'https://localhost:123/foo/bar?baz=bat'
42+
),
43+
array(
44+
8080,
45+
443,
46+
Request::create('https://localhost/foo/bar?baz=bat'),
47+
'http://localhost:8080/foo/bar?baz=bat'
48+
)
49+
);
50+
}
51+
}

0 commit comments

Comments
 (0)