5 class Csrf extends \Rsi\Fred\Security\Check{
10 public function check($expected =
false){
12 if(!$request->action || (($token = $request->csrfToken) === $this->token))
return true;
13 if(in_array($token,$invalid_tokens = $this->session->invalidTokens ?: []))
return null;
14 $invalid_tokens[] = $token;
15 $this->session->invalidTokens = $invalid_tokens;
20 return array_merge(parent::clientConfig(),[
'token' => $this->token]);
24 $tokens = $this->session->tokens ?: [];
25 if(!array_key_exists($name = $this->
component(
'request')->viewControllerName ?: $this->
component(
'router')->controllerName,$tokens))
26 $this->session->tokens = ($tokens += [$name => \Rsi\Str::random(rand($this->tokenLengthMin,$this->tokenLengthMax))]);
27 return $tokens[$name];
component($name)
Get a component (local or default).