51 $id = self::$selector->generate($name);
52 if (self::$storage->exists($id)) {
53 $value = self::$storage->get($id);
55 $value = self::$validator->generate();
56 self::$storage->set($id, $value);
58 return new UToken($id, $value);
78 public static function isValid(
string $id,
string $value): bool {
79 if (! self::$storage->exists($id)) {
83 return hash_equals(self::$storage->
get($id), $value);
93 public static function isValidByName(
string $name,
string $value): bool {
94 return self::isValid(self::$selector->generate($name), $value);
104 return self::$selector->generate($name);
114 return self::$validator->generate($value);
118 return \get_class(self::$validator);
122 return \get_class(self::$selector);
126 return \get_class(self::$storage);
130 return isset(self::$storage);
Ubiquity\security\csrf$CsrfManager This class is part of Ubiquity.
static removeToken(string $name)
Remove an existing token.
static isValidByName(string $name, string $value)
Returns whether the given CSRF token is valid, given his name.
static getSelector(string $name)
Return a selector corresponding to a name, using the active selector.
static isValid(string $id, string $value)
Returns whether the given CSRF token is valid, given his id.
static getValidatorClass()
static start(TokenStorageInterface $storage=null, GeneratorInterface $selector=null, GeneratorInterface $validator=null)
static getSelectorClass()
static getToken($name)
Generates or retrieve and return a token.
static generateValue(?string $value=null)
Generates a token value using the active validator.