Skip to content

Commit

Permalink
feature #80 Refactor 2.0 (sstok)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.0-dev branch.

Discussion
----------

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no (see UPGRADE-2.0.md)
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | Closes #53 
| License       | MIT

Commits
-------

e61be8f Move constraints and others to a library
77b0ff6 Modernize the bundle’s code-base
ebdcd33 Update documentation
  • Loading branch information
sstok authored Aug 26, 2017
2 parents 5d24381 + ebdcd33 commit d9abda0
Show file tree
Hide file tree
Showing 49 changed files with 533 additions and 2,426 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ core.autocrlf=lf
.gitignore export-ignore
.php_cs export-ignore
.scrutinizer.yml export-ignore
.styleci.yml export-ignore
.travis.yml export-ignore
.github export-ignore
phpunit.xml.dist export-ignore
Expand Down
7 changes: 4 additions & 3 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => array('syntax' => 'long'),
'array_syntax' => ['syntax' => 'short'],
'no_unreachable_default_argument_value' => false,
'braces' => array('allow_single_line_closure' => true),
'braces' => ['allow_single_line_closure' => true],
'header_comment' => ['header' => $header],
'heredoc_to_nowdoc' => false,
'phpdoc_annotation_without_dot' => false,
))
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(array(__DIR__.'/src', __DIR__.'/tests'))
->in([__DIR__.'/src', __DIR__.'/tests'])
)
;
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ matrix:
- php: 7.0
env: DEPENDENCIES='dev'
- php: 7.1
env: DEPENDENCIES='low'
env: DEPENDENCIES='low' lint=1
fast_finish: true

sudo: false
Expand All @@ -17,6 +17,10 @@ cache:

before_install:
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.3.2/php-cs-fixer.phar; fi
- if [[ $lint = 1 ]]; then composer global require --dev 'phpstan/phpstan:^0.8'; fi
- export PATH="$PATH:$HOME/.composer/vendor/bin"

install:
- if [ "$DEPENDENCIES" == "dev" ]; then composer config minimum-stability dev; fi;
Expand All @@ -26,5 +30,7 @@ install:
script:
- export SYMFONY_PHPUNIT_VERSION=5.7.19
- export SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
- export SYMFONY_DEPRECATIONS_HELPER=weak
- export SYMFONY_DEPRECATIONS_HELPER=strict
- vendor/bin/simple-phpunit --verbose
- if [[ $lint = 1 ]]; then php php-cs-fixer.phar fix --dry-run --diff --no-ansi; fi
- if [[ $lint = 1 ]]; then phpstan analyse -c phpstan.neon -l5 --ansi src tests; fi
66 changes: 37 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,83 @@
RollerworksPasswordStrengthBundle
=================================

This bundle provides a validator for ensuring strong passwords in Symfony2 applications.
This Symfony-bundle integrates the Rollerworks [PasswordStrengthValidator][1] into your Symfony application.

Passwords can be validated using either strength-levels (weak, medium, strong etc)
or by configuring explicit requirements (needs letters, numbers etc)
_The PasswordStrengthValidator provides various password strength validators for the Symfony Validator._

> This bundle provides the same level of functionality as the
> [PasswordStrengthBundle](https://github.com/jbafford/PasswordStrengthBundle) created by John Bafford.
> And is considered a replacement of the original bundle.
## Installation

### Step 1: Using Composer (recommended)

To install RollerworksPasswordStrengthBundle with Composer just run:
To install this package, add `rollerworks/password-strength-bundle` to your composer.json:

```bash
$ php composer.phar require rollerworks/password-strength-bundle
```

Now, Composer will automatically download all required files, and install them
Now, [Composer][2] will automatically download all required files, and install them
for you.

### Step2: Enable the bundle

**Note:** This step is **not** required for Symfony Flex.

Enable the bundle in the kernel:

```php
<?php

// in AppKernel::registerBundles()
$bundles = array(
$bundles = [
// ...
new Rollerworks\Bundle\PasswordStrengthBundle\RollerworksPasswordStrengthBundle(),
// ...
);
];
```

## Requirements

You need at least PHP 5.6 or PHP 7.0, mbstring is recommended but not required.
For the provided blacklist providers you may need SQLite3 or a PDO compatible driver.

Congratulations! You're ready!

## Basic Usage

**Caution:**
Documentation for the various constraints can be found in the [PasswordStrengthValidator][1] package.
See the [bundle reference configuration](docs/configuration.md) to configure usage with this bundle.

## Versioning

> The password validators do not enforce that the field must have a value!
> To make a field "required" use the [NotBlank constraint](http://symfony.com/doc/current/reference/constraints/NotBlank.html)
> in combination with the password validator(s).
For transparency and insight into the release cycle, and for striving
to maintain backward compatibility, this package is maintained under
the Semantic Versioning guidelines as much as possible.

### [Strength validation](docs/strength-validation.md)
Releases will be numbered with the following format:

Validates the passwords strength-level (weak, medium, strong etc).
`<major>.<minor>.<patch>`

### [Requirements validation](docs/requirements-validation.md)
And constructed with the following guidelines:

Validates the passwords using explicitly configured requirements (letters, caseDiff, numbers, requireSpecialCharacter).
* Breaking backward compatibility bumps the major (and resets the minor and patch)
* New additions without breaking backward compatibility bumps the minor (and resets the patch)
* Bug fixes and misc changes bumps the patch

### [Password blacklisting](docs/blacklist.md)
For more information on SemVer, please visit <http://semver.org/>.

There are times you want forbid (blacklist) a password from usage.
## License

Passwords are blacklisted using providers which can either an array or
(flat-file) database (which you can update regularly).
This library is released under the [MIT license](LICENSE).

With the default installation the following providers can be used.
## Contributing

* Noop: Default provider, does nothing.
* Array: Simple in memory blacklist provider (not recommended for big lists)
* Sqlite: Provides the blacklist using a SQLite3 database file.
* Pdo: Provides the blacklist using the PDO extension.
This is an open source project. If you'd like to contribute,
please read the [Contributing Guidelines][3]. If you're submitting
a pull request, please follow the guidelines in the [Submitting a Patch][4] section.

But building your own is also possible.
__Documentation on this is currently missing,
see current providers for more information.__
[1]: https://github.com/rollerworks/PasswordStrengthValidator
[2]: https://getcomposer.org/doc/00-intro.md
[3]: https://github.com/rollerworks/contributing
[4]: https://contributing.readthedocs.org/en/latest/code/patches.html
66 changes: 66 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
UPGRADE FROM 1.x to 2.0
=======================

Most of this bundle's content has been moved to a separate library
at https://github.com/rollerworks/PasswordStrengthValidator.

You will need to update your class imports to point to the component's
namespace.

All deprecated code has been removed. And support for Symfony 2 and anything
lower then PHP 5.6 was dropped. Official support for HHVM is also dropped.

You need at least Symfony 3.3 and PHP 5.6 (or PHP 7.0).

Constraints
-----------

The constraints have been moved to a separate library.
Update your imports to point to the new namespace.

Before:

```php
use Rollerworks\Bundle\PasswordStrengthBundle\Validator\Constraints as RollerworksPassword;
```

After:

```php
use Rollerworks\Component\PasswordStrength\Validator\Constraints as RollerworksPassword;
```

ChainLoader
-----------

A new `LazyChainLoader` has been added in the library, it is are recommended
to use this loader instead of the old `ChainLoader`.

To enable this loader update your configuration as follow.

Before:

```yaml
rollerworks_password_strength:
blacklist:
default_provider: rollerworks_password_strength.blacklist.provider.sqlite
providers:
chain:
providers:
- rollerworks_password_strength.blacklist.provider.array
- rollerworks_password_strength.blacklist.provider.sqlite
```
After:
```yaml
rollerworks_password_strength:
blacklist:
default_provider: rollerworks_password_strength.blacklist.provider.sqlite
providers:
chain:
lazy: true
providers:
- rollerworks_password_strength.blacklist.provider.array
- rollerworks_password_strength.blacklist.provider.sqlite
```
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
],
"require": {
"php": "^5.6 || ^7.0",
"symfony/framework-bundle": "^2.8.25 || ^3.3.6",
"symfony/console": "^2.8.25 || ^3.3.6",
"symfony/validator": "^2.8.25 || ^3.3.6",
"symfony/polyfill-mbstring": "^1.5.0",
"symfony/framework-bundle": "^3.3.6",
"rollerworks/password-strength-validator": "^1.0.1"
},
"require-dev": {
"symfony/phpunit-bridge": "^3.3.6",
"matthiasnoback/symfony-dependency-injection-test": "^1.1.0",
"matthiasnoback/symfony-service-definition-validator": "^1.2.2"
"matthiasnoback/symfony-service-definition-validator": "^1.2.2",
"symfony/var-dumper": "^3.3",
"symfony/console": "^3.3"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit d9abda0

Please sign in to comment.