summaryrefslogtreecommitdiffstats
path: root/user_guide_src
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-08-27 15:26:23 +0200
committerAndrey Andreev <narf@devilix.net>2014-08-27 15:26:23 +0200
commit487ccc9c8a21cb6338aab7173b3adda194d29c26 (patch)
tree1c8661b246337fa71348d687795a8c500f7897b3 /user_guide_src
parentd4afe4a074015af109f1ab482f486d71e0b883f4 (diff)
Add CI_Security::get_random_bytes() for CSRF & XSS token generation
Diffstat (limited to 'user_guide_src')
-rw-r--r--user_guide_src/source/changelog.rst3
-rw-r--r--user_guide_src/source/libraries/security.rst17
2 files changed, 18 insertions, 2 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 5c233efac..64a768977 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -508,9 +508,10 @@ Release Date: Not Released
- :doc:`Security Library <libraries/security>` changes include:
- - Added method ``strip_image_tags()``.
- Added ``$config['csrf_regeneration']``, which makes CSRF token regeneration optional.
- Added ``$config['csrf_exclude_uris']``, allowing for exclusion of URIs from the CSRF protection (regular expressions are supported).
+ - Added method ``strip_image_tags()``.
+ - Added method ``get_random_bytes()`` and switched CSRF & XSS token generation to use it.
- Modified method ``sanitize_filename()`` to read a public ``$filename_bad_chars`` property for getting the invalid characters list.
- Return status code of 403 instead of a 500 if CSRF protection is enabled but a token is missing from a request.
diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst
index c8d69d16f..0c51e342b 100644
--- a/user_guide_src/source/libraries/security.rst
+++ b/user_guide_src/source/libraries/security.rst
@@ -163,4 +163,19 @@ Class Reference
This method acts a lot like PHP's own native ``html_entity_decode()`` function in ENT_COMPAT mode, only
it tries to detect HTML entities that don't end in a semicolon because some browsers allow that.
- If the ``$charset`` parameter is left empty, then your configured ``$config['charset']`` value will be used. \ No newline at end of file
+ If the ``$charset`` parameter is left empty, then your configured ``$config['charset']`` value will be used.
+
+ .. method:: get_random_bytes($length)
+
+ :param int $length: Output length
+ :returns: A binary stream of random bytes or FALSE on failure
+ :rtype: string
+
+ A convenience method for getting proper random bytes via ``mcrypt_create_iv()``,
+ ``/dev/urandom`` or ``openssl_random_pseudo_bytes()`` (in that order), if one
+ of them is available.
+
+ Used for generating CSRF and XSS tokens.
+
+ .. note:: The output is NOT guaranteed to be cryptographically secure,
+ just the best attempt at that. \ No newline at end of file