csrf : update presentation
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4914 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
24
csrf.php
24
csrf.php
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
/** DomFramework
|
||||
@package domframework
|
||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
*/
|
||||
|
||||
/** CSRF protection
|
||||
* By default, the CSRF protection is active if a SESSION is active too.
|
||||
* It can be disabled if needed. An Exception is raised if the form is send
|
||||
* back without the token */
|
||||
* back without the token
|
||||
*/
|
||||
class csrf
|
||||
{
|
||||
/** Allow to disable the csrf protection */
|
||||
@@ -19,7 +21,8 @@ class csrf
|
||||
* enter information in form and submit) */
|
||||
private $csrfTimeout = 3600;
|
||||
|
||||
/** Manage the singleton */
|
||||
/** Manage the singleton
|
||||
*/
|
||||
public function __construct ()
|
||||
// {{{
|
||||
{
|
||||
@@ -36,7 +39,8 @@ class csrf
|
||||
}
|
||||
// }}}
|
||||
|
||||
/** This function return the token */
|
||||
/** This function return the token
|
||||
*/
|
||||
public function createToken ()
|
||||
// {{{
|
||||
{
|
||||
@@ -54,7 +58,8 @@ class csrf
|
||||
|
||||
/** Check if the provided token is the right token, defined last displayed
|
||||
* page
|
||||
* @param string $tokenFromUser The value csrf the user's token */
|
||||
* @param string $tokenFromUser The value csrf the user's token
|
||||
*/
|
||||
public function checkToken ($tokenFromUser)
|
||||
// {{{
|
||||
{
|
||||
@@ -80,7 +85,8 @@ class csrf
|
||||
}
|
||||
// }}}
|
||||
|
||||
/** Return the CSRF token in a hidden field */
|
||||
/** Return the CSRF token in a hidden field
|
||||
*/
|
||||
public function displayFormCSRF ()
|
||||
// {{{
|
||||
{
|
||||
@@ -92,7 +98,8 @@ class csrf
|
||||
}
|
||||
// }}}
|
||||
|
||||
/** Return the token if exists or create a new one if needed */
|
||||
/** Return the token if exists or create a new one if needed
|
||||
*/
|
||||
public function getToken ()
|
||||
// {{{
|
||||
{
|
||||
@@ -110,6 +117,7 @@ class csrf
|
||||
{
|
||||
$this->checkToken ($tokenFromUser);
|
||||
$_SESSION["domframework"]["csrf"]["csrfStart"] = microtime (TRUE);
|
||||
return true;
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user