1 | <?php |
||
30 | class SeaSurfer implements \Minotaur\Route\Plugin |
||
31 | { |
||
32 | /** |
||
33 | * The HTTP default methods |
||
34 | */ |
||
35 | protected const DEFAULT_METHODS = ['POST', 'PUT', 'DELETE']; |
||
36 | |||
37 | /** |
||
38 | * @var \Caridea\Session\CsrfPlugin |
||
39 | */ |
||
40 | protected $plugin; |
||
41 | |||
42 | /** |
||
43 | * @var \Minotaur\ErrorLogger |
||
44 | */ |
||
45 | protected $errorLogger; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $field; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $hostname; |
||
56 | |||
57 | /** |
||
58 | * @var bool |
||
59 | */ |
||
60 | protected $blockMissingSource; |
||
61 | |||
62 | /** |
||
63 | * @var array<string> The HTTP methods where this verification will happen |
||
64 | */ |
||
65 | protected $methods; |
||
66 | |||
67 | /** |
||
68 | * Creates a new SeaSurfer. |
||
69 | * |
||
70 | * @param $plugin - The CSRF session plugin |
||
71 | * @param $errorLogger - The error logger |
||
72 | * @param $field - The body field in which to find the CSRF token |
||
73 | * @param $hostname - The expected hostname to match |
||
74 | * @param $blockMissingSource - If we should stop requests with no Origin/Referer |
||
75 | * @param array<string> $methods - The HTTP methods under which this check is run |
||
76 | */ |
||
77 | 12 | public function __construct( |
|
92 | |||
93 | /** |
||
94 | * Gets the plugin priority; larger means first. |
||
95 | * |
||
96 | * @return - The plugin priority |
||
|
|||
97 | */ |
||
98 | public function getPriority(): int |
||
102 | |||
103 | /** |
||
104 | * Allows a plugin to issue a response before the request is dispatched. |
||
105 | * |
||
106 | * @param $request - The server request |
||
107 | * @param $response - The response |
||
108 | * @return - The response |
||
109 | */ |
||
110 | 12 | public function __invoke(Request $request, Response $response, callable $next): Response |
|
134 | |||
135 | /** |
||
136 | * Performs the verification. |
||
137 | */ |
||
138 | 10 | protected function verifyOrigin(Request $request): void |
|
162 | |||
163 | /** |
||
164 | * Performs the verification. |
||
165 | */ |
||
166 | 6 | protected function verifyToken(Request $request): void |
|
177 | } |
||
178 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.