From 2f4c3bc5c2fac164d1c58ac9aaa09ae070687443 Mon Sep 17 00:00:00 2001 From: Casey Hancock Date: Mon, 11 Aug 2014 12:52:20 -0400 Subject: CSRF whitelist supports regex Signed-off-by: Casey Hancock --- user_guide_src/source/libraries/security.rst | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'user_guide_src/source/libraries/security.rst') diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index fb875a0d9..566924398 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -97,6 +97,12 @@ by editing the 'csrf_exclude_uris' config parameter:: $config['csrf_exclude_uris'] = array('api/person/add'); +Optionally, you can use regular expressions as well as the ':any' and ':num' +wildcards in the URIs:: + + $config['csrf_exclude_uris'] = array('api/record/:num','api/title/[a-zA-Z]+'); + + *************** Class Reference *************** -- cgit v1.2.3-24-g4f1b From 8ef828129c559705447dd66a597071de5ae564a9 Mon Sep 17 00:00:00 2001 From: caseyh Date: Mon, 18 Aug 2014 05:13:11 -0400 Subject: Alter Pull #3176 - CSRF Whitelist --- user_guide_src/source/libraries/security.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'user_guide_src/source/libraries/security.rst') diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index 566924398..19480b4f8 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -97,10 +97,9 @@ by editing the 'csrf_exclude_uris' config parameter:: $config['csrf_exclude_uris'] = array('api/person/add'); -Optionally, you can use regular expressions as well as the ':any' and ':num' -wildcards in the URIs:: +Optionally, you can use regular expressions in the URIs:: - $config['csrf_exclude_uris'] = array('api/record/:num','api/title/[a-zA-Z]+'); + $config['csrf_exclude_uris'] = array('api/record/[0-9]+','api/title/[a-zA-Z]+'); *************** @@ -162,4 +161,4 @@ 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. -- cgit v1.2.3-24-g4f1b From 6c52096f4f9147244e9631b8040088025ae6e79d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 18 Aug 2014 12:24:42 +0300 Subject: [ci skip] Polish changes from PR #3176 --- user_guide_src/source/libraries/security.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'user_guide_src/source/libraries/security.rst') diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index 19480b4f8..c8d69d16f 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -97,10 +97,12 @@ by editing the 'csrf_exclude_uris' config parameter:: $config['csrf_exclude_uris'] = array('api/person/add'); -Optionally, you can use regular expressions in the URIs:: +Regular expressions are also supported (case-insensitive):: - $config['csrf_exclude_uris'] = array('api/record/[0-9]+','api/title/[a-zA-Z]+'); - + $config['csrf_exclude_uris'] = array( + 'api/record/[0-9]+', + 'api/title/[a-z]+' + ); *************** Class Reference @@ -161,4 +163,4 @@ 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. + If the ``$charset`` parameter is left empty, then your configured ``$config['charset']`` value will be used. \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 487ccc9c8a21cb6338aab7173b3adda194d29c26 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 27 Aug 2014 16:26:23 +0300 Subject: Add CI_Security::get_random_bytes() for CSRF & XSS token generation --- user_guide_src/source/libraries/security.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries/security.rst') 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 -- cgit v1.2.3-24-g4f1b