‪TYPO3CMS  ‪main
TYPO3\CMS\Core\FormProtection\AbstractFormProtection Class Reference
Inheritance diagram for TYPO3\CMS\Core\FormProtection\AbstractFormProtection:
TYPO3\CMS\Core\Security\BlockSerializationTrait TYPO3\CMS\Core\FormProtection\BackendFormProtection TYPO3\CMS\Core\FormProtection\DisabledFormProtection TYPO3\CMS\Core\FormProtection\FrontendFormProtection TYPO3\CMS\Core\FormProtection\InstallToolFormProtection TYPO3\CMS\Core\Tests\Unit\FormProtection\Fixtures\FormProtectionTesting

Public Member Functions

 clean ()
 
string generateToken ($formName, $action='', $formInstanceName='')
 
bool validateToken ($tokenId, $formName, $action='', $formInstanceName='')
 
 persistSessionToken ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Security\BlockSerializationTrait
 __wakeup ()
 

Protected Member Functions

string getSessionToken ()
 
string generateSessionToken ()
 
 createValidationErrorMessage ()
 
string retrieveSessionToken ()
 

Protected Attributes

Closure null $validationFailedCallback
 
string null $sessionToken
 

Detailed Description

This class provides protection against cross-site request forgery (XSRF/CSRF) for forms.

For documentation on how to use this class, please see the documentation of the corresponding subclasses

Definition at line 30 of file AbstractFormProtection.php.

Member Function Documentation

◆ clean()

TYPO3\CMS\Core\FormProtection\AbstractFormProtection::clean ( )

Deletes the session token and persists the (empty) token.

This function is intended to be called when a user logs on or off.

Definition at line 57 of file AbstractFormProtection.php.

References TYPO3\CMS\Core\FormProtection\AbstractFormProtection\persistSessionToken().

Referenced by TYPO3\CMS\Core\Tests\Unit\FormProtection\AbstractFormProtectionTest\cleanPersistsToken().

◆ createValidationErrorMessage()

TYPO3\CMS\Core\FormProtection\AbstractFormProtection::createValidationErrorMessage ( )
protected

Creates or displays an error message telling the user that the submitted form token is invalid.

Definition at line 124 of file AbstractFormProtection.php.

Referenced by TYPO3\CMS\Core\FormProtection\AbstractFormProtection\validateToken().

◆ generateSessionToken()

string TYPO3\CMS\Core\FormProtection\AbstractFormProtection::generateSessionToken ( )
protected

◆ generateToken()

string TYPO3\CMS\Core\FormProtection\AbstractFormProtection::generateToken (   $formName,
  $action = '',
  $formInstanceName = '' 
)

Generates a token for a form by hashing the given parameters with the secret session token.

Calling this function two times with the same parameters will create the same valid token during one user session.

Parameters
string$formName
string$action
string$formInstanceName
Returns
‪string the 32-character hex ID of the generated token
Exceptions

Reimplemented in TYPO3\CMS\Core\FormProtection\DisabledFormProtection.

Definition at line 76 of file AbstractFormProtection.php.

References TYPO3\CMS\Core\FormProtection\AbstractFormProtection\getSessionToken().

Referenced by TYPO3\CMS\Core\Tests\Unit\FormProtection\AbstractFormProtectionTest\generateTokenRetrievesTokenOnce(), TYPO3\CMS\Core\Tests\Unit\FormProtection\AbstractFormProtectionTest\validateTokenForInvalidFormNameCallsCreateValidationErrorMessage(), TYPO3\CMS\Core\Tests\Unit\FormProtection\AbstractFormProtectionTest\validateTokenForInvalidTokenCallsCreateValidationErrorMessage(), and TYPO3\CMS\Core\Tests\Unit\FormProtection\AbstractFormProtectionTest\validateTokenForValidTokenNotCallsCreateValidationErrorMessage().

◆ getSessionToken()

◆ persistSessionToken()

◆ retrieveSessionToken()

◆ validateToken()

Member Data Documentation

◆ $sessionToken

◆ $validationFailedCallback

Closure null TYPO3\CMS\Core\FormProtection\AbstractFormProtection::$validationFailedCallback
protected