1 | <?php |
||
29 | class CsrfPlugin extends Plugin |
||
30 | { |
||
31 | /** |
||
32 | * @var \Caridea\Session\Map A session value namespace |
||
33 | */ |
||
34 | protected $values; |
||
35 | |||
36 | /** |
||
37 | * Creates a new CSRF plugin. |
||
38 | */ |
||
39 | 1 | public function __construct() |
|
43 | |||
44 | /** |
||
45 | * Matches the client's CSRF token to the one stored in the session. |
||
46 | * |
||
47 | * @param string $value The client-supplied CSRF value |
||
48 | * @return bool |
||
49 | */ |
||
50 | 1 | public function isValid(string $value): bool |
|
54 | |||
55 | /** |
||
56 | * Gets the session CSRF token |
||
57 | * |
||
58 | * @return string|null The CSRF token (or null) |
||
59 | */ |
||
60 | 1 | public function getValue(): ?string |
|
64 | |||
65 | /** |
||
66 | * Recalculates the hash |
||
67 | */ |
||
68 | 1 | protected function regenerate(): void |
|
72 | |||
73 | /** |
||
74 | * {@inheritDoc} |
||
75 | */ |
||
76 | 1 | public function onRegenerate(Session $session): void |
|
80 | |||
81 | /** |
||
82 | * {@inheritDoc} |
||
83 | */ |
||
84 | 4 | public function onStart(Session $session): void |
|
91 | } |
||
92 |