forked from schmittjoh/JMSSecurityExtraBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c8b7e7
commit a636402
Showing
5 changed files
with
187 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,49 @@ | ||
Secure Random Number Generator | ||
------------------------------ | ||
|
||
.. versionadded :: 1.2 | ||
The Secure Random Number Generator was added. | ||
Introduction | ||
------------ | ||
In almost all applications, you need to generate random numbers that cannot be | ||
guessed by a possible attacker. Unfortunately, PHP does not provide capabilities | ||
to do this consistently on all platforms. | ||
|
||
This bundle ships with several seed provider implementations, and will choose | ||
the best provider possible depending on your PHP setup. | ||
|
||
You can enable the "security.secure_random" service with the following config:: | ||
Configuration | ||
------------- | ||
You can enable the "security.secure_random" service with the following config: | ||
|
||
.. configuration-block :: | ||
.. code-block :: yaml | ||
jms_security_extra: | ||
util: | ||
secure_random: ~ | ||
jms_security_extra: | ||
util: | ||
secure_random: ~ | ||
.. code-block :: xml | ||
<jms-security-extra> | ||
<util> | ||
<secure-random /> | ||
</util> | ||
</jms-security-extra> | ||
Also make sure to run ``php app/console doctrine:schema:update``, or create an | ||
equivalent migration to import the seed table. | ||
|
||
Usage | ||
----- | ||
The generator is made available with the service id ``security.secure_random``. | ||
|
||
.. code-block :: php | ||
<?php | ||
$generator = $this->container->get('security.secure_random'); | ||
$bytes = $generator->nextBytes(16); // 128-bit random number | ||