Skip to content
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

Remove deprecated StringUtils from WSSE custom auth provider #5966

Merged
merged 1 commit into from
Dec 18, 2015
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 2 additions & 18 deletions components/security/secure_tools.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
Securely Comparing Strings and Generating Random Numbers
========================================================
Securely Generating Random Numbers
==================================

The Symfony Security component comes with a collection of nice utilities
related to security. These utilities are used by Symfony, but you should
also use them if you want to solve the problem they address.

Comparing Strings
~~~~~~~~~~~~~~~~~

The time it takes to compare two strings depends on their differences. This
can be used by an attacker when the two strings represent a password for
instance; it is known as a `Timing attack`_.

Internally, when comparing two passwords, Symfony uses a constant-time
algorithm; you can use the same strategy in your own code thanks to the
:class:`Symfony\\Component\\Security\\Core\\Util\\StringUtils` class::

use Symfony\Component\Security\Core\Util\StringUtils;

// is some known string (e.g. password) equal to some user input?
$bool = StringUtils::equals($knownString, $userInput);

Generating a Secure random Number
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
11 changes: 1 addition & 10 deletions cookbook/security/custom_authentication_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ the ``PasswordDigest`` header value matches with the user's password.
use Symfony\Component\Security\Core\Exception\NonceExpiredException;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use AppBundle\Security\Authentication\Token\WsseUserToken;
use Symfony\Component\Security\Core\Util\StringUtils;

class WsseProvider implements AuthenticationProviderInterface
{
Expand Down Expand Up @@ -273,7 +272,7 @@ the ``PasswordDigest`` header value matches with the user's password.
// Validate Secret
$expected = base64_encode(sha1(base64_decode($nonce).$created.$secret, true));

return StringUtils::equals($expected, $digest);
return hash_equals($expected, $digest);
}

public function supports(TokenInterface $token)
Expand All @@ -290,14 +289,6 @@ the ``PasswordDigest`` header value matches with the user's password.
provider for the given token. In the case of multiple providers, the
authentication manager will then move to the next provider in the list.

.. note::

The comparison of the expected and the provided digests uses a constant
time comparison provided by the
:method:`Symfony\\Component\\Security\\Core\\Util\\StringUtils::equals`
method of the ``StringUtils`` class. It is used to mitigate possible
`timing attacks`_.

The Factory
-----------

Expand Down