18 Commits

Author SHA1 Message Date
Christophe Coevoet
55624532a8 Updated the installation instructions 2014-03-13 14:32:21 +01:00
Christophe Coevoet
683df6494a Added a note about the Symfony 2.5 feature 2014-03-13 14:29:17 +01:00
Christophe Coevoet
00a417d4ee Added the scrutinizer badges 2014-03-13 14:27:01 +01:00
Christophe Coevoet
a86856e23d Added the external code coverage on Scrutinizer 2014-03-13 14:18:52 +01:00
Christophe Coevoet
f0c230e5aa Added testing on more versions
This tests on PHP 5.6 and 5.6 and HHVM.
It also adds some builds with specific Symfony versions rather than the latest stable.
2014-03-13 14:15:14 +01:00
Christophe Coevoet
c4fec6f11d Merge pull request #10 from marc-f/master
Added bcrypt and pbkdf2 encoder support

Closes #7
2014-03-13 14:11:47 +01:00
Marc Feininger
3e0c0123fd merged smottt/FOSAdvancedEncoderBundle for adding bcrypt
Conflicts:
	DependencyInjection/Configuration.php
	DependencyInjection/FOSAdvancedEncoderExtension.php
	Tests/DependencyInjection/FOSAdvancedEncoderExtensionTest.php
2014-03-13 13:50:05 +01:00
marc-f
37cc94863c added support for pbkdf2 Encoder 2014-03-12 11:40:09 +01:00
metod
3db4b7f690 fix constructor parameters for BCryptPasswordEncoder in Symfony 2.3 2013-10-26 13:38:09 +02:00
Kris Wallsmith
bc9d59affb updated constraints 2013-06-03 13:37:24 -06:00
metod
5d77b0a599 added support for BCrypt Encoder 2013-06-01 14:44:23 +02:00
Christophe Coevoet
e3ef1f1317 Merge pull request #5 from pulse00/composerpatch
Updated symfony dependencies for 2.2 support
2013-01-12 03:56:19 -08:00
Robert Gruendler
2726627405 updated symfony dependencies for 2.2 support 2013-01-12 09:25:31 +01:00
Christophe Coevoet
9c69e092db Switched the testsuite to composer 2012-06-20 00:05:09 +02:00
Christophe Coevoet
f30fc908ac Fixed CS 2012-06-19 23:56:41 +02:00
Christophe Coevoet
531cf302bc Updated the constraint to require 2.1 2012-06-20 00:33:36 +03:00
Christophe Coevoet
c75786a658 Merge pull request #4 from FabienPennequin/symfony2.1
Update for latest changes in Security component of Symfony2.1
2012-06-19 14:32:30 -07:00
Fabien Pennequin
0ffd8b1ce9 Update for latest changes in Security component of Symfony2.1 2012-06-19 23:20:24 +02:00
15 changed files with 110 additions and 155 deletions

6
.gitignore vendored
View File

@@ -1,4 +1,4 @@
phpunit.xml
Tests/autoload.php
vendor/symfony
vendor/
composer.lock
composer.phar

View File

@@ -1,16 +1,30 @@
language: php
php:
- 5.3
- 5.4
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
env:
- SYMFONY_VERSION=v2.0.12
- SYMFONY_VERSION=origin/2.0
- SYMFONY_VERSION=origin/master
matrix:
include:
- php: 5.5
env: SYMFONY_VERSION='2.3.*'
- php: 5.5
env: SYMFONY_VERSION='2.5.*@dev'
before_script: php vendor/vendors.php
before_script:
- sh -c 'if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony=$SYMFONY_VERSION; fi;'
- composer install --no-interaction --prefer-source
script: phpunit -v --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
notifications:
email:
- friendsofsymfony-dev@googlegroups.com
email:
- friendsofsymfony-dev@googlegroups.com

View File

@@ -51,6 +51,9 @@ class Configuration implements ConfigurationInterface
->booleanNode('ignore_case')->defaultFalse()->end()
->booleanNode('encode_as_base64')->defaultTrue()->end()
->scalarNode('iterations')->defaultValue(5000)->end()
->scalarNode('cost')->defaultValue(13)->end()
->scalarNode('hash_algorithm')->defaultValue('sha512')->end()
->scalarNode('key_length')->defaultValue(40)->end()
->scalarNode('id')->end()
->end()
->end()

View File

@@ -53,6 +53,31 @@ class FOSAdvancedEncoderExtension extends Extension
);
}
// bcrypt encoder
if ('bcrypt' === $config['algorithm']) {
$arguments = array($config['cost']);
return array(
'class' => new Parameter('security.encoder.bcrypt.class'),
'arguments' => $arguments,
);
}
// pbkdf2 encoder
if ('pbkdf2' === $config['algorithm']) {
$arguments = array(
$config['hash_algorithm'],
$config['encode_as_base64'],
$config['iterations'],
$config['key_length'],
);
return array(
'class' => new Parameter('security.encoder.pbkdf2.class'),
'arguments' => $arguments,
);
}
// message digest encoder
$arguments = array(
$config['algorithm'],

View File

@@ -5,6 +5,10 @@ The FOSAdvancedEncoderBundle adds support for changing the encoder on an
instance basis instead of using the same encoder for all instances of a class.
[![Build Status](https://secure.travis-ci.org/FriendsOfSymfony/FOSAdvancedEncoderBundle.png?branch=master)](http://travis-ci.org/FriendsOfSymfony/FOSAdvancedEncoderBundle)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/FriendsOfSymfony/FOSAdvancedEncoderBundle/badges/quality-score.png?s=dccf1912b87c5739d73100a09997fcf3204f551b)](https://scrutinizer-ci.com/g/FriendsOfSymfony/FOSAdvancedEncoderBundle/)
[![Code Coverage](https://scrutinizer-ci.com/g/FriendsOfSymfony/FOSAdvancedEncoderBundle/badges/coverage.png?s=27e29c5ea428937a7527343676ccc304281b049f)](https://scrutinizer-ci.com/g/FriendsOfSymfony/FOSAdvancedEncoderBundle/)
> **Note:** this bundle is not necessary as of Symfony 2.5. The same feature is available in the Security component itself.
Documentation
-------------
@@ -17,14 +21,12 @@ file in this bundle:
Installation
------------
All the installation instructions are located in [documentation](https://github.com/friendsofsymfony/FOSAdvancedEncoderBundle/blob/master/Resources/doc/index.md).
All the installation instructions are located in [documentation](Resources/doc/index.md).
License
-------
This bundle is under the MIT license. See the complete license in the bundle:
Resources/meta/LICENSE
This bundle is under the MIT license. See the complete license in the bundle: [Resources/meta/LICENSE](Resources/meta/LICENSE)
Reporting an issue or a feature request
---------------------------------------

View File

@@ -11,4 +11,4 @@
</service>
</services>
</container>
</container>

View File

@@ -9,42 +9,17 @@ instance basis instead of using the same encoder for all instances of a class.
## Installation
### Add FOSAdvancedEncoderBundle to your vendor/bundles dir
### Add FOSAdvancedEncoderBundle to your project
Ultimately, the FOSAdvancedEncoderBundle files should be downloaded to the
`vendor/bundles/FOS/AdvancedEncoderBundle` directory.
The recommended way to install the bundle is through Composer.
This can be done in several ways, depending on your preference. The first
method is the standard Symfony2 method.
**Using the vendors script**
Add the following lines in your `deps` file:
[FOSAdvancedEncoderBundle]
git=git://github.com/FriendsOfSymfony/FOSAdvancedEncoderBundle.git
target=bundles/FOS/AdvancedEncoderBundle
Now, run the vendors script to download the bundle:
php bin/vendors install
**Using submodules**
If you prefer instead to use git submodules, the run the following:
git submodule add git://github.com/friendsofsymfony/FOSAdvancedEncoderBundle.git vendor/bundles/FOS/AdvancedEncoderBundle
### Register the FOS namespace
// app/autoload.php
$loader->registerNamespaces(array(
'FOS' => __DIR__.'/../vendor/bundles',
// your other namespaces
));
```bash
$ composer require 'friendsofsymfony/advanced-encoder-bundle:~1.0'
```
### Add FOSAdvancedEncoderBundle to your application kernel
```php
// app/AppKernel.php
public function registerBundles()
{
@@ -54,6 +29,7 @@ If you prefer instead to use git submodules, the run the following:
// ...
);
}
```
## Configure the encoders
@@ -62,18 +38,20 @@ the bundle. They are identified by a name used to reference them later. The
configuration keys available are exactly the same than for the SecurityBundle
encoder configuration.
fos_advanced_encoder:
encoders:
my_encoder:
algorithm: sha512
iterations: 5000
encode_as_base64: true
another_encoder: sha1 # shortcut for the previous way
my_plain_encoder:
algorithm: plaintext
ignore_case: false
my_custom_encoder:
id: some_service_id
```yaml
fos_advanced_encoder:
encoders:
my_encoder:
algorithm: sha512
iterations: 5000
encode_as_base64: true
another_encoder: sha1 # shortcut for the previous way
my_plain_encoder:
algorithm: plaintext
ignore_case: false
my_custom_encoder:
id: some_service_id
```
## Use the bundle

View File

@@ -11,8 +11,6 @@
namespace FOS\AdvancedEncoderBundle\Security\Encoder;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
/**
* @author Christophe Coevoet <stof@notk.org>
*/
@@ -26,5 +24,5 @@ interface EncoderAwareInterface
*
* @return string
*/
function getEncoderName();
public function getEncoderName();
}

View File

@@ -13,7 +13,6 @@ namespace FOS\AdvancedEncoderBundle\Security\Encoder;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @author Christophe Coevoet <stof@notk.org>
@@ -26,8 +25,8 @@ class EncoderFactory implements EncoderFactoryInterface
/**
* Constructor.
*
* @param \Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface $genericFactory
* @param array $encoders
* @param EncoderFactoryInterface $genericFactory
* @param array $encoders
*/
public function __construct(EncoderFactoryInterface $genericFactory, array $encoders)
{
@@ -35,7 +34,7 @@ class EncoderFactory implements EncoderFactoryInterface
$this->encoders = $encoders;
}
public function getEncoder(UserInterface $user)
public function getEncoder($user)
{
if (!$user instanceof EncoderAwareInterface) {
return $this->genericFactory->getEncoder($user);
@@ -61,8 +60,8 @@ class EncoderFactory implements EncoderFactoryInterface
/**
* Creates an encoder for the given algorithm.
*
* @param array $config
* @return \Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface
* @param array $config
* @return PasswordEncoderInterface
*/
protected function createEncoder(array $config)
{

View File

@@ -43,6 +43,17 @@ class FOSAdvancedEncoderExtensionTest extends \PHPUnit_Framework_TestCase
'custom' => array(
'id' => 'acme_demo.encoder',
),
'bcrypt' => array(
'algorithm' => 'bcrypt',
'cost' => 16,
),
'pbkdf2' => array(
'algorithm' => 'pbkdf2',
'hash_algorithm' => 'sha512',
'encode_as_base64' => false,
'iterations' => 2,
'key_length' => 40,
),
),
);
$loader->load(array($config), $container);
@@ -65,6 +76,14 @@ class FOSAdvancedEncoderExtensionTest extends \PHPUnit_Framework_TestCase
'arguments' => array(false),
),
'custom' => new Reference('acme_demo.encoder'),
'bcrypt' => array(
'class' => new Parameter('security.encoder.bcrypt.class'),
'arguments' => array(16),
),
'pbkdf2' => array(
'class' => new Parameter('security.encoder.pbkdf2.class'),
'arguments' => array('sha512', false, 2, 40),
),
)
)
);

View File

@@ -1,32 +0,0 @@
<?php
/*
* This file is part of the FOSAdvancedEncoderBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$vendorDir = __DIR__.'/../vendor';
require_once $vendorDir.'/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => $vendorDir.'/symfony/src',
));
$loader->register();
spl_autoload_register(function($class) {
if (0 === strpos($class, 'FOS\\AdvancedEncoderBundle\\')) {
$path = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 2)).'.php';
if (!stream_resolve_include_path($path)) {
return false;
}
require_once $path;
return true;
}
});

View File

@@ -1,16 +0,0 @@
<?php
/*
* This file is part of the FOSAdvancedEncoderBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if (file_exists($file = __DIR__.'/autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
require_once $file;
}

View File

@@ -13,8 +13,8 @@
],
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": ">=2.0,<2.2",
"symfony/security-bundle": ">=2.0,<2.2"
"symfony/framework-bundle": "~2.1",
"symfony/security-bundle": "~2.1"
},
"autoload": {
"psr-0": { "FOS\\AdvancedEncoderBundle": "" }

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="FOSAdvancedEncoderBundle">
<directory suffix="Test.php">./Tests</directory>

35
vendor/vendors.php vendored
View File

@@ -1,35 +0,0 @@
#!/usr/bin/env php
<?php
/*
* This file is part of the FOSAdvancedEncoderBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
set_time_limit(0);
if (isset($argv[1])) {
$_SERVER['SYMFONY_VERSION'] = $argv[1];
}
$vendorDir = __DIR__;
$deps = array(
array('symfony', 'http://github.com/symfony/symfony', isset($_SERVER['SYMFONY_VERSION']) ? $_SERVER['SYMFONY_VERSION'] : 'origin/master'),
);
foreach ($deps as $dep) {
list($name, $url, $rev) = $dep;
echo "> Installing/Updating $name\n";
$installDir = $vendorDir.'/'.$name;
if (!is_dir($installDir)) {
system(sprintf('git clone -q %s %s', escapeshellarg($url), escapeshellarg($installDir)));
}
system(sprintf('cd %s && git fetch -q origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
}