1 | <?php |
||
25 | class CsrfToken |
||
26 | { |
||
27 | /** |
||
28 | * The length of the tokens |
||
29 | */ |
||
30 | const LENGTH = 56; |
||
31 | |||
32 | /** |
||
33 | * @var \OpCacheGUI\Storage\keyValuePair Instance of a key value storage |
||
34 | */ |
||
35 | private $storage; |
||
36 | |||
37 | /** |
||
38 | * Creates instance |
||
39 | * |
||
40 | * @param \OpCacheGUI\Storage\KeyValuePair $storage Instance of a key value storage |
||
41 | */ |
||
42 | 4 | public function __construct(KeyValuePair $storage) |
|
46 | |||
47 | /** |
||
48 | * Gets the stored CSRF token |
||
49 | * |
||
50 | * @return string The stored CSRF token |
||
51 | */ |
||
52 | 4 | public function get() |
|
60 | |||
61 | /** |
||
62 | * Validates the supplied token against the stored token |
||
63 | * |
||
64 | * @param string $token The token to validate |
||
65 | * |
||
66 | * @return boolean True when the supplied token matches the stored token |
||
67 | */ |
||
68 | 2 | public function validate($token) |
|
72 | |||
73 | /** |
||
74 | * Generates a new secure CSRF token |
||
75 | * |
||
76 | * @return string The generated CSRF token |
||
77 | * @throws InsufficientRandomData |
||
78 | */ |
||
79 | 1 | private function generate() |
|
89 | } |
||
90 |