-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security] Handle properly 'auto' option for remember me cookie security
- Loading branch information
Showing
5 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional; | ||
|
||
use Symfony\Component\HttpFoundation\ResponseHeaderBag; | ||
|
||
class RememberMeCookieTest extends AbstractWebTestCase | ||
{ | ||
/** @dataProvider getSessionRememberMeSecureCookieFlagAutoHttpsMap */ | ||
public function testSessionRememberMeSecureCookieFlagAuto($https, $expectedSecureFlag) | ||
{ | ||
$client = $this->createClient(['test_case' => 'RememberMeCookie', 'root_config' => 'config.yml']); | ||
|
||
$client->request('POST', '/login', [ | ||
'_username' => 'test', | ||
'_password' => 'test', | ||
], [], [ | ||
'HTTPS' => (int) $https, | ||
]); | ||
|
||
$cookies = $client->getResponse()->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY); | ||
|
||
$this->assertEquals($expectedSecureFlag, $cookies['']['/']['REMEMBERME']->isSecure()); | ||
} | ||
|
||
public function getSessionRememberMeSecureCookieFlagAutoHttpsMap() | ||
{ | ||
return [ | ||
[true, true], | ||
[false, false], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Bundle\SecurityBundle\SecurityBundle; | ||
|
||
return [ | ||
new FrameworkBundle(), | ||
new SecurityBundle(), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
imports: | ||
- { resource: ./../config/framework.yml } | ||
|
||
security: | ||
encoders: | ||
Symfony\Component\Security\Core\User\User: plaintext | ||
|
||
providers: | ||
in_memory: | ||
memory: | ||
users: | ||
test: { password: test, roles: [ROLE_USER] } | ||
|
||
firewalls: | ||
default: | ||
form_login: | ||
check_path: login | ||
remember_me: true | ||
require_previous_session: false | ||
remember_me: | ||
always_remember_me: true | ||
secret: key | ||
secure: auto | ||
logout: ~ | ||
anonymous: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
login: | ||
path: /login |