Skip to content

Commit c35deb0

Browse files
Trigger build
2 parents 42ba803 + 957a0b8 commit c35deb0

16 files changed

+141
-17
lines changed

UPGRADE-4.4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ MonologBridge
4141

4242
* The `RouteProcessor` has been marked final.
4343

44+
Security
45+
--------
46+
47+
* Implementations of `PasswordEncoderInterface` and `UserPasswordEncoderInterface` should add a new `needsRehash()` method
48+
4449
TwigBridge
4550
----------
4651

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ Routing
313313
Security
314314
--------
315315

316+
* Implementations of `PasswordEncoderInterface` and `UserPasswordEncoderInterface` must have a new `needsRehash()` method
316317
* The `Role` and `SwitchUserRole` classes have been removed.
317318
* The `getReachableRoles()` method of the `RoleHierarchy` class has been removed. It has been replaced by the new
318319
`getReachableRoleNames()` method.

src/Symfony/Bundle/TwigBundle/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* marked the `TemplateIterator` as `internal`
8+
49
4.2.0
510
-----
611

src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TemplateCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInte
2828
private $twig;
2929
private $iterator;
3030

31-
public function __construct(ContainerInterface $container, \Traversable $iterator)
31+
public function __construct(ContainerInterface $container, iterable $iterator)
3232
{
3333
// As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
3434
$this->container = $container;

src/Symfony/Bundle/TwigBundle/TemplateIterator.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* Iterator for all templates in bundles and in the application Resources directory.
1919
*
2020
* @author Fabien Potencier <fabien@symfony.com>
21+
*
22+
* @internal since Symfony 4.4
2123
*/
2224
class TemplateIterator implements \IteratorAggregate
2325
{
@@ -31,7 +33,7 @@ class TemplateIterator implements \IteratorAggregate
3133
* @param KernelInterface $kernel A KernelInterface instance
3234
* @param string $rootDir The directory where global templates can be stored
3335
* @param array $paths Additional Twig paths to warm
34-
* @param string $defaultPath The directory where global templates can be stored
36+
* @param string|null $defaultPath The directory where global templates can be stored
3537
*/
3638
public function __construct(KernelInterface $kernel, string $rootDir, array $paths = [], string $defaultPath = null)
3739
{
@@ -50,40 +52,46 @@ public function getIterator()
5052
return $this->templates;
5153
}
5254

53-
$this->templates = array_merge(
54-
$this->findTemplatesInDirectory($this->rootDir.'/Resources/views'),
55-
$this->findTemplatesInDirectory($this->defaultPath, null, ['bundles'])
56-
);
55+
$templates = $this->findTemplatesInDirectory($this->rootDir.'/Resources/views');
56+
57+
if (null !== $this->defaultPath) {
58+
$templates = array_merge(
59+
$templates,
60+
$this->findTemplatesInDirectory($this->defaultPath, null, ['bundles'])
61+
);
62+
}
5763
foreach ($this->kernel->getBundles() as $bundle) {
5864
$name = $bundle->getName();
5965
if ('Bundle' === substr($name, -6)) {
6066
$name = substr($name, 0, -6);
6167
}
6268

63-
$this->templates = array_merge(
64-
$this->templates,
69+
$templates = array_merge(
70+
$templates,
6571
$this->findTemplatesInDirectory($bundle->getPath().'/Resources/views', $name),
66-
$this->findTemplatesInDirectory($this->rootDir.'/Resources/'.$bundle->getName().'/views', $name),
67-
$this->findTemplatesInDirectory($this->defaultPath.'/bundles/'.$bundle->getName(), $name)
72+
$this->findTemplatesInDirectory($this->rootDir.'/Resources/'.$bundle->getName().'/views', $name)
6873
);
74+
if (null !== $this->defaultPath) {
75+
$templates = array_merge(
76+
$templates,
77+
$this->findTemplatesInDirectory($this->defaultPath.'/bundles/'.$bundle->getName(), $name)
78+
);
79+
}
6980
}
7081

7182
foreach ($this->paths as $dir => $namespace) {
72-
$this->templates = array_merge($this->templates, $this->findTemplatesInDirectory($dir, $namespace));
83+
$templates = array_merge($templates, $this->findTemplatesInDirectory($dir, $namespace));
7384
}
7485

75-
return $this->templates = new \ArrayIterator(array_unique($this->templates));
86+
return $this->templates = new \ArrayIterator(array_unique($templates));
7687
}
7788

7889
/**
7990
* Find templates in the given directory.
8091
*
81-
* @param string $dir The directory where to look for templates
82-
* @param string|null $namespace The template namespace
83-
*
84-
* @return array
92+
* @return string[]
8593
*/
86-
private function findTemplatesInDirectory($dir, $namespace = null, array $excludeDirs = [])
94+
private function findTemplatesInDirectory(string $dir, string $namespace = null, array $excludeDirs = []): array
8795
{
8896
if (!is_dir($dir)) {
8997
return [];

src/Symfony/Component/Security/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* Added method `needsRehash()` to `PasswordEncoderInterface` and `UserPasswordEncoderInterface`
8+
49
4.3.0
510
-----
611

src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ abstract class BasePasswordEncoder implements PasswordEncoderInterface
2020
{
2121
const MAX_PASSWORD_LENGTH = 4096;
2222

23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function needsRehash(string $encoded): bool
27+
{
28+
return false;
29+
}
30+
2331
/**
2432
* Demerges a merge password and salt string.
2533
*

src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,12 @@ public function isPasswordValid($encoded, $raw, $salt)
8787

8888
return \strlen($raw) <= self::MAX_PASSWORD_LENGTH && password_verify($raw, $encoded);
8989
}
90+
91+
/**
92+
* {@inheritdoc}
93+
*/
94+
public function needsRehash(string $encoded): bool
95+
{
96+
return password_needs_rehash($encoded, $this->algo, $this->options);
97+
}
9098
}

src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* PasswordEncoderInterface is the interface for all encoders.
1818
*
1919
* @author Fabien Potencier <fabien@symfony.com>
20+
*
21+
* @method bool needsRehash(string $encoded)
2022
*/
2123
interface PasswordEncoderInterface
2224
{

src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,20 @@ public function isPasswordValid($encoded, $raw, $salt)
9999

100100
throw new LogicException('Libsodium is not available. You should either install the sodium extension, upgrade to PHP 7.2+ or use a different encoder.');
101101
}
102+
103+
/**
104+
* {@inheritdoc}
105+
*/
106+
public function needsRehash(string $encoded): bool
107+
{
108+
if (\function_exists('sodium_crypto_pwhash_str_needs_rehash')) {
109+
return \sodium_crypto_pwhash_str_needs_rehash($encoded, $this->opsLimit, $this->memLimit);
110+
}
111+
112+
if (\extension_loaded('libsodium')) {
113+
return \Sodium\crypto_pwhash_str_needs_rehash($encoded, $this->opsLimit, $this->memLimit);
114+
}
115+
116+
throw new LogicException('Libsodium is not available. You should either install the sodium extension, upgrade to PHP 7.2+ or use a different encoder.');
117+
}
102118
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy