Zend\Validator\Csrf
Synopsis
class Csrf
extends AbstractValidator
{
- // constants
- const NOT_SAME = 'notSame';
- // members
- protected array $messageTemplates;
- protected mixed $hash;
- protected array $hashCache;
- protected string $name;
- protected string $salt;
- protected Container $session;
- protected int|null $timeout;
- // Inherited members from AbstractValidator
- protected mixed $value;
- protected TranslatorInterface $defaultTranslator;
- protected string $defaultTranslatorTextDomain;
- protected integer $messageLength;
- protected array $abstractOptions;
- // methods
- public void __construct()
- public bool isValid()
- public Csrf setName()
- public string getName()
- public Csrf setSession()
- public Container getSession()
- public Csrf setSalt()
- public string getSalt()
- public string getHash()
- public string getSessionName()
- public Csrf setTimeout()
- public int getTimeout()
- protected void initCsrfToken()
- protected void generateHash()
- protected string generateTokenId()
- protected null|string getValidationToken()
- protected string formatHash()
- protected string getTokenFromHash()
- protected string getTokenIdFromHash()
- // Inherited methods from AbstractValidator
- public void __construct()
- public mixed getOption()
- public array getOptions()
- public AbstractValidator setOptions()
- public array getMessages()
- public bool __invoke()
- public array getMessageVariables()
- public array getMessageTemplates()
- public AbstractValidator setMessage()
- public AbstractValidator setMessages()
- public mixed __get()
- protected string createMessage()
- protected void error()
- protected mixed getValue()
- protected void setValue()
- public AbstractValidator setValueObscured()
- public bool isValueObscured()
- public AbstractValidator setTranslator()
- public TranslatorInterface|null getTranslator()
- public bool hasTranslator()
- public AbstractValidator setTranslatorTextDomain()
- public string getTranslatorTextDomain()
- public static void setDefaultTranslator()
- public static TranslatorInterface|null getDefaultTranslator()
- public static bool hasDefaultTranslator()
- public static void setDefaultTranslatorTextDomain()
- public static string getDefaultTranslatorTextDomain()
- public AbstractValidator setTranslatorEnabled()
- public bool isTranslatorEnabled()
- public static int getMessageLength()
- public static void setMessageLength()
- protected string translateMessage()
Hierarchy
Extends
Tasks
Line | Task |
---|---|
+ | unused, left here to avoid BC breaks |
323 | remove, here for BC |
Constants
Name | Value |
---|---|
NOT_SAME | 'notSame' |
Members
protected
- $abstractOptions
- $defaultTranslator
—
Zend\Validator\Translator\TranslatorInterface
Default translation object for all validate objects - $defaultTranslatorTextDomain
—
string
Default text domain to be used with translator - $hash
—
mixed
Actual hash used. - $hashCache
—
array
Static cache of the session names to generated hashes - $messageLength
—
int
Limits the maximum returned length of an error message - $messageTemplates
—
array
Error messages - $name
—
string
Name of CSRF element (used to create non-colliding hashes) - $salt
—
string
Salt for CSRF token - $session — Zend\Session\Container
- $timeout
—
Zend\Validator\int|null
TTL for CSRF token - $value
—
mixed
The value to be validated
Methods
protected
- formatHash()
- generateHash() — Generate CSRF token
- generateTokenId()
- getTokenFromHash()
- getTokenIdFromHash()
- getValidationToken() — Get validation token
- initCsrfToken() — Initialize CSRF token in session
public
- __construct() — Constructor
- getHash() — Retrieve CSRF token
- getName() — Get CSRF name
- getSalt() — Retrieve salt for CSRF token
- getSession() — Get session container
- getSessionName() — Get session namespace for CSRF token
- getTimeout() — Get CSRF session token timeout
- isValid() — Does the provided token match the one generated?
- setName() — Set CSRF name
- setSalt() — Salt for CSRF token
- setSession() — Set session container
- setTimeout() — Set timeout for CSRF session token
Inherited from Zend\Validator\AbstractValidator
protected
- createMessage() — Constructs and returns a validation failure message with the given message key and value.
- error()
- getValue() — Returns the validation value
- setValue() — Sets the value to be validated and clears the messages and errors arrays
- translateMessage() — Translate a validation message
public
- __get() — Magic function returns the value of the requested property, if and only if it is the value or a message variable.
- __invoke() — Invoke as command
- getDefaultTranslator() — Get default translation object for all validate objects
- getDefaultTranslatorTextDomain() — Get default translation text domain for all validate objects
- getMessageLength() — Returns the maximum allowed message length
- getMessageTemplates() — Returns the message templates from the validator
- getMessageVariables() — Returns an array of the names of variables that are used in constructing validation failure messages
- getMessages() — Returns array of validation failure messages
- getOption() — Returns an option
- getOptions() — Returns all available options
- getTranslator() — Return translation object
- getTranslatorTextDomain() — Return the translation text domain
- hasDefaultTranslator() — Is there a default translation object set?
- hasTranslator() — Does this validator have its own specific translator?
- isTranslatorEnabled() — Is translation enabled?
- isValueObscured() — Retrieve flag indicating whether or not value should be obfuscated in messages
- setDefaultTranslator() — Set default translation object for all validate objects
- setDefaultTranslatorTextDomain() — Set default translation text domain for all validate objects
- setMessage() — Sets the validation failure message template for a particular key
- setMessageLength() — Sets the maximum allowed message length
- setMessages() — Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.
- setOptions() — Sets one or multiple options
- setTranslator() — Set translation object
- setTranslatorEnabled() — Indicate whether or not translation should be enabled
- setTranslatorTextDomain() — Set translation text domain
- setValueObscured() — Set flag indicating whether or not value should be obfuscated in messages