From ff768fbdd9a05ae8aab9e28f0c18b83d6e001b7e Mon Sep 17 00:00:00 2001 From: noniagriconomie Date: Wed, 12 Aug 2020 11:21:02 +0200 Subject: [PATCH 1/4] [Notifier] add doc for free mobile dsn --- .../Notifier/Bridge/FreeMobile/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/README.md b/src/Symfony/Component/Notifier/Bridge/FreeMobile/README.md index a117b04c66..e48257483f 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/README.md +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/README.md @@ -5,6 +5,21 @@ Provides Free Mobile integration for Symfony Notifier. This provider allows you to receive an SMS notification on your personal mobile number. +DSN example +----------- + +``` +// .env file +FREE_MOBILE_DSN=freemobile://LOGIN:PASSWORD@default?phone=PHONE +``` + +where: + - `LOGIN` is your Free Mobile login + - `PASSWORD` is the token displayed in your account + - `PHONE` is your Free Mobile phone number + +See your account info at https://mobile.free.fr/moncompte/index.php?page=options + Resources --------- From 93aea910d939d33cddc07b8dbd0cff2d8dfc2ea0 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Tue, 25 Aug 2020 17:09:29 +0200 Subject: [PATCH 2/4] Fixed autoLogin() returning null --- .../Authenticator/RememberMeAuthenticator.php | 13 ++++--- .../RememberMeAuthenticatorTest.php | 37 +++++++------------ 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php b/src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php index f5aa016ad1..61ad2aa2ee 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php +++ b/src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php @@ -19,7 +19,6 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport; -use Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices; use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface; /** @@ -57,13 +56,12 @@ class RememberMeAuthenticator implements InteractiveAuthenticatorInterface return false; } - if (($cookie = $request->attributes->get(AbstractRememberMeServices::COOKIE_ATTR_NAME)) && null === $cookie->getValue()) { + $token = $this->rememberMeServices->autoLogin($request); + if (null === $token) { return false; } - if (isset($this->options['name']) && !$request->cookies->has($this->options['name'])) { - return false; - } + $request->attributes->set('_remember_me_token', $token); // the `null` return value indicates that this authenticator supports lazy firewalls return null; @@ -71,7 +69,10 @@ class RememberMeAuthenticator implements InteractiveAuthenticatorInterface public function authenticate(Request $request): PassportInterface { - $token = $this->rememberMeServices->autoLogin($request); + $token = $request->attributes->get('_remember_me_token'); + if (null === $token) { + throw new \LogicException('No remember me token is set.'); + } return new SelfValidatingPassport($token->getUser()); } diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php index d95e681281..0ad757efe1 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php @@ -12,14 +12,12 @@ namespace Symfony\Component\Security\Http\Tests\Authenticator; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\User\User; use Symfony\Component\Security\Http\Authenticator\RememberMeAuthenticator; -use Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices; use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface; class RememberMeAuthenticatorTest extends TestCase @@ -37,8 +35,6 @@ class RememberMeAuthenticatorTest extends TestCase 'name' => '_remember_me_cookie', ]); $this->request = new Request(); - $this->request->cookies->set('_remember_me_cookie', $val = $this->generateCookieValue()); - $this->request->attributes->set(AbstractRememberMeServices::COOKIE_ATTR_NAME, new Cookie('_remember_me_cookie', $val)); } public function testSupportsTokenStorageWithToken() @@ -48,39 +44,34 @@ class RememberMeAuthenticatorTest extends TestCase $this->assertFalse($this->authenticator->supports($this->request)); } - public function testSupportsRequestWithoutAttribute() + /** + * @dataProvider provideSupportsData + */ + public function testSupports($autoLoginResult, $support) { - $this->request->attributes->remove(AbstractRememberMeServices::COOKIE_ATTR_NAME); + $this->rememberMeServices->expects($this->once())->method('autoLogin')->with($this->request)->willReturn($autoLoginResult); - $this->assertNull($this->authenticator->supports($this->request)); + $this->assertSame($support, $this->authenticator->supports($this->request)); } - public function testSupportsRequestWithoutCookie() + public function provideSupportsData() { - $this->request->cookies->remove('_remember_me_cookie'); - - $this->assertFalse($this->authenticator->supports($this->request)); - } - - public function testSupports() - { - $this->assertNull($this->authenticator->supports($this->request)); + yield [null, false]; + yield [$this->createMock(TokenInterface::class), null]; } public function testAuthenticate() { - $this->rememberMeServices->expects($this->once()) - ->method('autoLogin') - ->with($this->request) - ->willReturn(new RememberMeToken($user = new User('wouter', 'test'), 'main', 'secret')); - + $this->request->attributes->set('_remember_me_token', new RememberMeToken($user = new User('wouter', 'test'), 'main', 'secret')); $passport = $this->authenticator->authenticate($this->request); $this->assertSame($user, $passport->getUser()); } - private function generateCookieValue() + public function testAuthenticateWithoutToken() { - return base64_encode(implode(AbstractRememberMeServices::COOKIE_DELIMITER, ['part1', 'part2'])); + $this->expectException(\LogicException::class); + + $this->authenticator->authenticate($this->request); } } From 7cd510604109c288690e97d4c0f3e13cf2142232 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 26 Aug 2020 08:25:12 +0200 Subject: [PATCH 3/4] fix more numeric cases changing in PHP 8 --- src/Symfony/Component/Yaml/Inline.php | 2 +- src/Symfony/Component/Yaml/Tests/InlineTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 11efebca44..a0c804d1d0 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -210,7 +210,7 @@ class Inline return 'false'; case ctype_digit($value): return \is_string($value) ? "'$value'" : (int) $value; - case is_numeric($value) && false === strpos($value, "\n"): + case is_numeric($value) && false === strpos($value, "\f") && false === strpos($value, "\n") && false === strpos($value, "\r") && false === strpos($value, "\t") && false === strpos($value, "\v"): $locale = setlocale(LC_NUMERIC, 0); if (false !== $locale) { setlocale(LC_NUMERIC, 'C'); diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 362421ff8e..69b8033a0f 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -570,6 +570,14 @@ class InlineTest extends TestCase ['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']], ['{ foo: { bar: { 1: 2, baz: 3 } } }', ['foo' => ['bar' => [1 => 2, 'baz' => 3]]]], + + // numeric strings with trailing whitespaces + ["'0123 '", '0123 '], + ['"0123\f"', "0123\f"], + ['"0123\n"', "0123\n"], + ['"0123\r"', "0123\r"], + ['"0123\t"', "0123\t"], + ['"0123\v"', "0123\v"], ]; } From ab92e9f4c3726b397f175d6bcbdea704427f504a Mon Sep 17 00:00:00 2001 From: noniagriconomie Date: Fri, 21 Aug 2020 19:05:22 +0200 Subject: [PATCH 4/4] Backport: Improve link script with rollback when using symlink --- link | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/link b/link index 9f42fe9512..99bad694c4 100755 --- a/link +++ b/link @@ -18,19 +18,22 @@ require __DIR__.'/src/Symfony/Component/Filesystem/Filesystem.php'; use Symfony\Component\Filesystem\Filesystem; /** - * Links dependencies to components to a local clone of the main symfony/symfony GitHub repository. + * Links dependencies of a project to a local clone of the main symfony/symfony GitHub repository. * * @author Kévin Dunglas */ $copy = false !== $k = array_search('--copy', $argv, true); $copy && array_splice($argv, $k, 1); +$rollback = false !== $k = array_search('--rollback', $argv, true); +$rollback && array_splice($argv, $k, 1); $pathToProject = $argv[1] ?? getcwd(); if (!is_dir("$pathToProject/vendor/symfony")) { - echo 'Link (or copy) dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL; + echo 'Links dependencies of a project to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL; echo "Usage: $argv[0] /path/to/the/project".PHP_EOL; echo ' Use `--copy` to copy dependencies instead of symlink'.PHP_EOL.PHP_EOL; + echo ' Use `--rollback` to rollback'.PHP_EOL.PHP_EOL; echo "The directory \"$pathToProject\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL; exit(1); } @@ -51,12 +54,19 @@ foreach ($directories as $dir) { foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { $package = 'symfony/'.basename($dir); - if (!$copy && is_link($dir)) { - echo "\"$package\" is already a symlink, skipping.".PHP_EOL; + + if (!isset($sfPackages[$package])) { continue; } - if (!isset($sfPackages[$package])) { + if ($rollback) { + $filesystem->remove($dir); + echo "\"$package\" has been rollback from \"$sfPackages[$package]\".".PHP_EOL; + continue; + } + + if (!$copy && is_link($dir)) { + echo "\"$package\" is already a symlink, skipping.".PHP_EOL; continue; } @@ -76,3 +86,7 @@ foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as foreach (glob("$pathToProject/var/cache/*", GLOB_NOSORT) as $cacheDir) { $filesystem->remove($cacheDir); } + +if ($rollback) { + echo PHP_EOL."Rollback done, do not forget to run \"composer install\" in your project \"$pathToProject\".".PHP_EOL; +}