allowedRedirectUris = [$allowedRedirectUri]; } elseif (\is_array($allowedRedirectUri)) { $this->allowedRedirectUris = $allowedRedirectUri; } else { $this->allowedRedirectUris = []; } } /** * Validates the redirect uri. * * @param string $redirectUri * * @return bool Return true if valid, false otherwise */ public function validateRedirectUri($redirectUri) { if ($this->isLoopbackUri($redirectUri)) { return $this->matchUriExcludingPort($redirectUri); } return $this->matchExactUri($redirectUri); } /** * According to section 7.3 of rfc8252, loopback uris are: * - "http://127.0.0.1:{port}/{path}" for IPv4 * - "http://[::1]:{port}/{path}" for IPv6 * * @param string $redirectUri * * @return bool */ private function isLoopbackUri($redirectUri) { try { $uri = Uri::createFromString($redirectUri); } catch (SyntaxError $e) { return false; } return $uri->getScheme() === 'http' && (\in_array($uri->getHost(), ['127.0.0.1', '[::1]'], true)); } /** * Find an exact match among allowed uris * * @param string $redirectUri * * @return bool Return true if an exact match is found, false otherwise */ private function matchExactUri($redirectUri) { return \in_array($redirectUri, $this->allowedRedirectUris, true); } /** * Find a match among allowed uris, allowing for different port numbers * * @param string $redirectUri * * @return bool Return true if a match is found, false otherwise */ private function matchUriExcludingPort($redirectUri) { $parsedUrl = $this->parseUrlAndRemovePort($redirectUri); foreach ($this->allowedRedirectUris as $allowedRedirectUri) { if ($parsedUrl === $this->parseUrlAndRemovePort($allowedRedirectUri)) { return true; } } return false; } /** * Parse an url like \parse_url, excluding the port * * @param string $url * * @return array */ private function parseUrlAndRemovePort($url) { $uri = Uri::createFromString($url); return (string) $uri->withPort(null); } } __halt_compiler();----SIGNATURE:----dIkkHqA6M4t5RNc0Wg+bC4Ha98g0ZsktkBZnuLalpmCjBpE6J8ewwHwEzUi9U1YV6S1Sjihj9QTwyEBLzHJv65fJK/bcawJAN0/WQM/qt27gWqANBhD4lddOaHe02rjoYZeDvjOMOEHBmop+Rb3QDNBlsojd2T2xyXB03hiEVi746NCKganoRjmKhfBDHZ6YBcxkrrOj13BkbsTF4/acb7wlUgPQvyYFJ0WzFK3CUYXVcC/IDMpZ10g1oQTgKS2gybDFUrSrw1Hw/wizbSp29CumoMdjepAENeVd4gm/zwgp8F83DWO2pPJ6FSWlMz5R7XsPrGu/feIqhX6ZMbSqM2hQtRG2WIygmioQseVkrFNIWbyMIxQT5sGZ9tgO+sYOgXAVctlkthVXxBzY4YqxWKifmf2B1nMaW5+IUCAC/DgF8Ur3rpLUhxc19vrSmV1WRYABN39f/0Rgjk2du9bQMSLWoEYmqs7JpgjP8kizJpcFeVUan3bRYgvIE5PdScyJqz6AO90huS2DYA/XQrp06hAVpICfl/5/nVrLISUaHsqf3vNeTbaLte9zJI/ok4SZSwCdY7cTOI1N8f88F0jgzXo/qMjFrniczDukWYtOY3aYHdw1AnyTP+yXdt1dAXZjZiA+SVKBsub9UiOFBA9zUmiRSWOJUE0+0AhrF63nvMg=----ATTACHMENT:----OTYwMjA0OTE4OTAxNzQ4NSA4NDQ4NTI3MTkzOTU5NjI3IDE0MTkwOTQ4MTg2MzI2Mzk=