Skip to content

Commit

Permalink
feature symfony#5966 Remove deprecated StringUtils from WSSE custom a…
Browse files Browse the repository at this point in the history
…uth provider (pimpreneil)

This PR was merged into the 2.8 branch.

Discussion
----------

Remove deprecated StringUtils from WSSE custom auth provider

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | >=2.8
| Fixed tickets | N/A

Commits
-------

099ea85 Remove deprecated StringUtils from WSSE custom auth provider
  • Loading branch information
wouterj committed Dec 18, 2015
2 parents fac6023 + 099ea85 commit 2648a7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
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

0 comments on commit 2648a7d

Please sign in to comment.