PassSecurityBundle
, (*1)
The PassSecurityBundle It is designed to help test passwords for entry into the list of unsafe., (*2)
Bundle only checks the password in the list, and tells you under what number it was found, the decision about how much it is safe, take you (or you can report it to your users, and to shift the responsibility on them)., (*3)
I strongly advise against using any password that can be found on this list., (*4)
Demo example
Website: https://demo-pass-security-bundle.herokuapp.com, (*5)
Source code: https://github.com/Nidhognit/demo-pass-security-bundle, (*6)
Instalation
If you use composer, open a command console, enter your project directory and execute the following command:, (*7)
$ composer require nidhognit/pass-security-bundle "0.2"
Enable the Bundle in AppKernel like this:, (*8)
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new \Nidhognit\PassSecurityBundle\PassSecurityBundle(),
);
// ...
}
// ...
}
The bundle comes with a sensible default configuration. If you need to change them, you can define these in config.yml
(more information for bundle configuration below)., (*9)
How to use
In below example, we imagine, that you want check passwords for user before they submit form:, (*10)
// ...
/**
* @Route("/ajax_password_check")
* @param Request $request
* @return JsonResponse
*/
public function ajaxPasswordCheckAction(Request $request)
{
$password = $request->get('password'); //password from user
$limit = null; // if you want, you can limit password search (type of this variable must bu integer)
$passManager = $this->get('pass_security.manager');
$number = $passManager->getNumberOrNull($password, $limit);
return new JsonResponse(['number' => $number]);
}
// ...
In this case you must use HTTPS, if you use HTTP - it is very dangerous because of the possibility of MITM., (*11)
You also can use console command:, (*12)
$ bin/console passbundle:check 123456
Where 123456
- your custom password., (*13)
Documentation
Default configuration:, (*14)
pass_security:
type: "file"
Value "type" can be file
(default), base
, custom
., (*15)
Type "file"
In this case, the password will be read from the file. Default file have 100 000 passwords, and you can use you own file:, (*16)
pass_security:
type: "file"
file: "path/custom.txt"
Where:
* castom.txt
- must have ".txt" etentions;
* path
- is absolute path;
* Each new password in the file begins on a new line;, (*17)
Default bundle have some pass files:
* Pass100k
(selected by default) - list of 100 000 offen used passwords;
* Pass1M
- list of 1 000 000 offen used passwords;, (*18)
Example (select file with 1 000 000 passwords):
```yml
pass_security:
type: "file"
file: Pass1M, (*19)
### Type "base"
In this case, the passwords will be read from the database. Default configuration looks like this:
```yml
pass_security:
type: "base"
You can configure the fololowing variables:, (*20)
pass_security:
type: "base"
class: \AcmeBundle\Entity\MyCustomEntity
repository: AcmeBundle:MyCustomEntity
Requirements:
* MyCustomEntity
must implement the interface InterfacePassSecurityEntity
., (*21)
You can use you own passwords data in database, or you can transfer all the data from file with following console command:, (*22)
$ bin/console passbundle:base
This command will write all passwords from "file" (by default Pass100K) in table, who define in entity "class" (by default 'pass_security_base').
By default this command will use Entity, and if you use very big file, it can take a lot of time and memory., (*23)
If you do not need to create entities, you can use the option "--sql" like this, (*24)
$ bin/console passbundle:base --sql
Type "custom"
You can also create your own service, for check passwords., (*25)
pass_security:
type: "custom"
custom_service: "acme_bundle.my_service"
Requirements:
* Service must implement the interface InterfaceReader
;
* The service must be available for download from container;, (*26)