Created
September 26, 2011 19:08
-
-
Save jmikola/1243080 to your computer and use it in GitHub Desktop.
Custom MessageDigestPasswordEncoder class for Symfony2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Bundle\MainBundle\Security\Encoder; | |
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder as BaseMessageDigestPasswordEncoder; | |
/** | |
* Extends MessageDigestPasswordEncoder to support custom merging of password and salt strings. | |
* | |
* @author Jeremy Mikola <jmikola@gmail.com> | |
*/ | |
class MessageDigestPasswordEncoder extends BaseMessageDigestPasswordEncoder | |
{ | |
/** | |
* Demerges a merge password and salt string. | |
* | |
* @param string $mergedPasswordSalt The merged password and salt string | |
* @throws \BadMethodCallException always | |
*/ | |
protected function demergePasswordAndSalt($mergedPasswordSalt) | |
{ | |
throw new \BadMethodCallException('Password and salt cannot be demerged.'); | |
} | |
/** | |
* Merges a password and a salt. | |
* | |
* @param string $password | |
* @param string $salt | |
* @return string | |
*/ | |
protected function mergePasswordAndSalt($password, $salt) | |
{ | |
return $salt . $password; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<container xmlns="http://symfony.com/schema/dic/services" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | |
<parameters> | |
<parameter key="security.encoder.digest.class">Application\Bundle\MainBundle\Security\Encoder\MessageDigestPasswordEncoder</parameter> | |
</parameters> | |
</container> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment