Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] removeplaintext 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:6.4fromkbond:security/plaintext-hasher
May 27, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 40 additions & 50 deletionssecurity/passwords.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,75 +124,65 @@ Further in this article, you can find a

.. 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">
Copy link
MemberAuthor

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should be<srv:when> as this code snippet defines the SecurityBundle XML namespace as the default namespace and uses thesrv alias for the XML namespace of the DI component

Copy link
Member

Choose a reason for hiding this comment

The 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 asecurity alias (not registered on the top-level element) for nodes of the SecurityBundle config

kbond reacted with confused emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What should we do here? Can this snippet be fixed easily? Otherwise, we could just remove it. Symfony plans to remove XML config support "soon", so this is not important. Thanks.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd vote to remove

<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
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp