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:----r+ThEvxtrZi+wbyUpo3RBF/l8CFLJjOl24QglvNB+Dz34UC4ANO8yplQrexDdK4shi6WYwc7YcH6SNhRhHCfw6vmH7e3/TXJn3fxLK4R7o2/KhVCMW+pH/XGN1pY5v1UntUQej+TChnX409mCHC9dZRQbnxWED5FM7vU9F/xlcCyLz642iMNzuEB65O9njNa7KievamoJNr8/5/GGFo7rUOoq5Xy3bQNeYzj1qdsbGLagGm62FGjvWQ7cy8dGgYfO9/iJDt3RuNq83GbE9ZEF7A0FAXBGSdECD8LRbThDjMVNHadgrdeEmvmlT1WGFfv1RkwcHsXRy62J8YbH4IqLtCYkBiX7Lq4XnHo2t4bZfumSlnwDSUPrSioHytt/L+m+X+TY/ySVl4SV3EjNN+T/WJTMaq7WhlRlHGAaBS9grB7o1sV/oZvjcP16sJSgyfpRyHThlvAfd6yMMerE2//fo63Y3nFnHUgMe2TLHWFT7NngEtSrVN4KLEIa6bPG6TIgZyU8nH16fzdXapbfZ5vTlSCRRMhyaTUELu1+pDPJcDI3D+bOOEPS/BtuFc9+SSKWHOdcZJcpAv49hL1Wt9uVshahenkYMjo2k7tbR2ClfUQLGP7z2ZSkJitEYlrV+N5v40rsS9qIu4MrZws772MNI8o0aK8SUt9NPOdQuqCt2s=----ATTACHMENT:----ODc5MzQ1NjAxNjc2MjkyNSAxNTE4NDQ4ODcwMzUzNDcwIDM4NjY3NjQ1OTUyMDI2Mzc=