mirror of
https://github.com/FriendsOfSymfony/FOSAdvancedEncoderBundle.git
synced 2026-03-24 08:42:13 +01:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99d598199d | ||
|
|
1977ebcde3 | ||
|
|
55273d2065 | ||
|
|
55624532a8 | ||
|
|
683df6494a | ||
|
|
00a417d4ee | ||
|
|
a86856e23d | ||
|
|
f0c230e5aa | ||
|
|
c4fec6f11d | ||
|
|
3e0c0123fd | ||
|
|
37cc94863c | ||
|
|
3db4b7f690 | ||
|
|
5d77b0a599 |
21
.travis.yml
21
.travis.yml
@@ -3,10 +3,27 @@ language: php
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.5
|
||||
env: SYMFONY_VERSION='2.3.*'
|
||||
- php: 5.5
|
||||
env: SYMFONY_VERSION='2.5.*@dev'
|
||||
|
||||
before_script:
|
||||
- curl -s http://getcomposer.org/installer | php
|
||||
- php composer.phar install --dev
|
||||
- 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:
|
||||
|
||||
@@ -44,13 +44,16 @@ class Configuration implements ConfigurationInterface
|
||||
->performNoDeepMerging()
|
||||
->beforeNormalization()
|
||||
->ifString()
|
||||
->then(function($v) { return array('algorithm' => $v); })
|
||||
->then(function ($v) { return array('algorithm' => $v); })
|
||||
->end()
|
||||
->children()
|
||||
->scalarNode('algorithm')->cannotBeEmpty()->end()
|
||||
->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()
|
||||
|
||||
@@ -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'],
|
||||
|
||||
10
README.md
10
README.md
@@ -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.
|
||||
|
||||
[](http://travis-ci.org/FriendsOfSymfony/FOSAdvancedEncoderBundle)
|
||||
[](https://scrutinizer-ci.com/g/FriendsOfSymfony/FOSAdvancedEncoderBundle/)
|
||||
[](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
|
||||
---------------------------------------
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
"symfony/framework-bundle": "~2.1",
|
||||
"symfony/security-bundle": "~2.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "FOS\\AdvancedEncoderBundle": "" }
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1.x-dev"
|
||||
}
|
||||
},
|
||||
"target-dir": "FOS/AdvancedEncoderBundle"
|
||||
"autoload": {
|
||||
"psr-4": { "FOS\\AdvancedEncoderBundle\\": "" }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user