1 | <?php |
||
15 | final class CsrfHeaderCheckMiddleware implements MiddlewareInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var IsSafeHttpRequestInterface |
||
19 | */ |
||
20 | private $isSafeHttpRequest; |
||
21 | |||
22 | public function __construct(IsSafeHttpRequestInterface $isSafeHttpRequest) |
||
26 | |||
27 | /** |
||
28 | * Process an incoming server request and return a response, optionally delegating |
||
29 | * to the next middleware component to create the response. |
||
30 | * |
||
31 | * @param ServerRequestInterface $request |
||
32 | * @param DelegateInterface $delegate |
||
33 | * @return ResponseInterface |
||
34 | * @throws CsrfHeaderCheckMiddlewareException |
||
35 | */ |
||
36 | public function process(ServerRequestInterface $request, DelegateInterface $delegate) |
||
48 | |||
49 | private function getSourceOrigin(ServerRequestInterface $request): string |
||
63 | |||
64 | private function getTargetOrigin(ServerRequestInterface $request): string |
||
76 | |||
77 | private function removePortFromHost(string $host) |
||
81 | |||
82 | /** |
||
83 | * Returns the header, throws an exception if the header is specified more that one in the request. |
||
84 | * Returns null if nothing found. |
||
85 | * |
||
86 | * @param ServerRequestInterface $request |
||
87 | * @param string $header |
||
88 | * @return string|null |
||
89 | * @throws CsrfHeaderCheckMiddlewareException |
||
90 | */ |
||
91 | private function getHeaderLine(ServerRequestInterface $request, string $header) |
||
102 | } |
||
103 |