-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Security] remove plaintext
password hasher usage
#20986
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
base: 7.3
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,75 +124,65 @@ | |
|
||
.. code-block:: yaml | ||
|
||
# config/packages/test/security.yaml | ||
security: | ||
# ... | ||
|
||
password_hashers: | ||
# Use your user class name here | ||
App\Entity\User: | ||
algorithm: plaintext # disable hashing (only do this in tests!) | ||
|
||
# or use the lowest possible values | ||
App\Entity\User: | ||
algorithm: auto # This should be the same value as in config/packages/security.yaml | ||
cost: 4 # Lowest possible value for bcrypt | ||
time_cost: 3 # Lowest possible value for argon | ||
memory_cost: 10 # Lowest possible value for argon | ||
# config/packages/security.yaml | ||
when@test: | ||
security: | ||
# ... | ||
|
||
password_hashers: | ||
# Use your user class name here | ||
App\Entity\User: | ||
algorithm: auto | ||
cost: 4 # Lowest possible value for bcrypt | ||
time_cost: 3 # Lowest possible value for argon | ||
memory_cost: 10 # Lowest possible value for argon | ||
|
||
.. code-block:: xml | ||
|
||
<!-- config/packages/test/security.xml --> | ||
<!-- config/packages/security.xml --> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<srv:container xmlns="http://symfony.com/schema/dic/security" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:srv="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
https://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<config> | ||
<!-- class: Use your user class name here --> | ||
<!-- algorithm: disable hashing (only do this in tests!) --> | ||
<security:password-hasher | ||
class="App\Entity\User" | ||
algorithm="plaintext" | ||
/> | ||
|
||
<!-- or use the lowest possible values --> | ||
<!-- algorithm: This should be the same value as in config/packages/security.yaml --> | ||
<!-- cost: Lowest possible value for bcrypt --> | ||
<!-- time_cost: Lowest possible value for argon --> | ||
<!-- memory_cost: Lowest possible value for argon --> | ||
<security:password-hasher | ||
class="App\Entity\User" | ||
algorithm="auto" | ||
cost="4" | ||
time_cost="3" | ||
memory_cost="10" | ||
/> | ||
</config> | ||
<when env="test"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, actually, this XML code snippet is already a mess, as it mixes cases, sometimes using a |
||
<config> | ||
<!-- class: Use your user class name here --> | ||
<!-- cost: Lowest possible value for bcrypt --> | ||
<!-- time_cost: Lowest possible value for argon --> | ||
<!-- memory_cost: Lowest possible value for argon --> | ||
<security:password-hasher | ||
class="App\Entity\User" | ||
algorithm="auto" | ||
cost="4" | ||
time_cost="3" | ||
memory_cost="10" | ||
/> | ||
</config> | ||
</when> | ||
</srv:container> | ||
|
||
.. code-block:: php | ||
|
||
// config/packages/test/security.php | ||
// config/packages/security.php | ||
use App\Entity\User; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
use Symfony\Config\SecurityConfig; | ||
|
||
return static function (SecurityConfig $security): void { | ||
return static function (SecurityConfig $security, ContainerConfigurator $container): void { | ||
// ... | ||
|
||
// Use your user class name here | ||
$security->passwordHasher(User::class) | ||
->algorithm('plaintext'); // disable hashing (only do this in tests!) | ||
|
||
// or use the lowest possible values | ||
$security->passwordHasher(User::class) | ||
->algorithm('auto') // This should be the same value as in config/packages/security.yaml | ||
->cost(4) // Lowest possible value for bcrypt | ||
->timeCost(2) // Lowest possible value for argon | ||
->memoryCost(10) // Lowest possible value for argon | ||
; | ||
if ('test' === $container->env()) { | ||
// Use your user class name here | ||
$security->passwordHasher(User::class) | ||
->algorithm('auto') // This should be the same value as in config/packages/security.yaml | ||
->cost(4) // Lowest possible value for bcrypt | ||
->timeCost(2) // Lowest possible value for argon | ||
->memoryCost(10) // Lowest possible value for argon | ||
; | ||
} | ||
}; | ||
|
||
Hashing the Password | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super confident on these xml/php config changes - please review.