From 246fe889ee3b0bbf93dc8dd3ee2cb3f9bf4546f2 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 7 Nov 2023 16:48:20 +0000 Subject: [PATCH 01/16] ProxyUrl: Determine whether to proxy via web service --- config/vufind/config.ini | 12 ++++ .../src/VuFind/View/Helper/Root/ProxyUrl.php | 58 +++++++++++++++++-- .../View/Helper/Root/ProxyUrlFactory.php | 4 +- 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index a6f3e1b06e0..425f3ab6400 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -1449,6 +1449,18 @@ replace_other_urls = true ; to false. ;prefixLinks = true +; Use a web service to determine whether to prefix each link, ignoring prefixLinks +; above. Query the configured URL via HTTP GET and a single query parameter, 'url', +; set to the link domain. The web service should return a body with a single number, +; '1' to prefix and '0' if not. The web service should be hosted closely such that +; query time is minimal. +; See https://github.com/lehigh-university-libraries/ezproxy-url-checker for an OSS +; implementation of this protocol that extrats the answers from EZproxy config. +;prefixLinksWebServiceUrl = http://localhost:8080/proxyUrl + +; Duration (seconds) to cache web service response data. Default is 600. +;prefixLinksWebServiceCacheLifetime = 600 + ; Uncomment the following line and change the password to something secret to enable ; EZproxy ticket authentication. ;secret = "verysecretpassword" diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 6bc353d1ac2..9ad2d126791 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -29,6 +29,8 @@ namespace VuFind\View\Helper\Root; +use Laminas\Cache\Storage\Adapter\AbstractAdapter as CacheAdapter; + /** * Proxy URL view helper * @@ -38,8 +40,12 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ -class ProxyUrl extends \Laminas\View\Helper\AbstractHelper +class ProxyUrl extends \Laminas\View\Helper\AbstractHelper implements + \VuFindHttp\HttpServiceAwareInterface { + use \VuFind\Cache\CacheTrait; + use \VuFindHttp\HttpServiceAwareTrait; + /** * VuFind configuration * @@ -50,11 +56,14 @@ class ProxyUrl extends \Laminas\View\Helper\AbstractHelper /** * Constructor * + * @param CacheAdapter $cache Cache for web service repsonses * @param \Laminas\Config\Config $config VuFind configuration */ - public function __construct($config = null) + public function __construct(CacheAdapter $cache = null, $config = null) { $this->config = $config; + $this->setCacheStorage($cache); + $this->cacheLifetime = intval($config->EZproxy->prefixLinksWebServiceCacheLifetime ?? 600); } /** @@ -66,10 +75,51 @@ public function __construct($config = null) */ public function __invoke($url) { - $usePrefix = !isset($this->config->EZproxy->prefixLinks) - || $this->config->EZproxy->prefixLinks; + $useWebService = $this->config->EZproxy->prefixLinksWebServiceUrl ?? false; + if ($useWebService) { + $usePrefix = $this->checkUrl($url); + } else { + $usePrefix = $this->config->EZproxy->prefixLinks ?? true; + } + return ($usePrefix && isset($this->config->EZproxy->host)) ? $this->config->EZproxy->host . '/login?qurl=' . urlencode($url) : $url; } + + /** + * Check whether the given URL requires the proxy prefix. Cache the repsonse. + * + * @param string $url The raw URL to check + * + * @return bool Whether the URL should be prefixed + */ + protected function checkUrl($url) + { + $domain = parse_url($url, PHP_URL_HOST); + $cacheKey = parse_url($url, PHP_URL_SCHEME) . '://' . $domain; + $usePrefix = $this->getCachedData("proxyUrl-domainToUsePrefix-$cacheKey"); + if (null === $usePrefix) { + $usePrefix = $this->queryWebService($domain); + $this->putCachedData("proxyUrl-domainToUsePrefix-$cacheKey", $usePrefix); + } + return $usePrefix; + } + + /** + * Query the web service on whether to prefix URLs to a given domain. + * + * @param $domain The domain + * + * @return bool Whether the URL should be prefixed + */ + protected function queryWebService($domain) + { + $prefixLinksWebServiceUrl = $this->config->EZproxy->prefixLinksWebServiceUrl; + $queryUrl = $prefixLinksWebServiceUrl . '?url=' . $domain; + $client = $this->httpService->createClient($queryUrl); + $response = $client->send(); + $responseData = $response->getContent(); + return ('1' === $responseData); + } } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php index 7dce962f835..d8e53f0936b 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php @@ -68,8 +68,10 @@ public function __invoke( if (!empty($options)) { throw new \Exception('Unexpected options sent to factory.'); } + $cache = $container->get(\VuFind\Cache\Manager::class) + ->getCache('object'); $config = $container->get(\VuFind\Config\PluginManager::class) ->get('config'); - return new $requestedName($config); + return new $requestedName($cache, $config); } } From f69b4b40afbf77ed25cdc4daccc191df0521780c Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 7 Nov 2023 17:47:31 +0000 Subject: [PATCH 02/16] Handle connection exceptions --- .../src/VuFind/View/Helper/Root/ProxyUrl.php | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 9ad2d126791..4877bbc966d 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -29,6 +29,7 @@ namespace VuFind\View\Helper\Root; +use Exception; use Laminas\Cache\Storage\Adapter\AbstractAdapter as CacheAdapter; /** @@ -41,9 +42,11 @@ * @link https://vufind.org/wiki/development Wiki */ class ProxyUrl extends \Laminas\View\Helper\AbstractHelper implements + \Laminas\Log\LoggerAwareInterface, \VuFindHttp\HttpServiceAwareInterface { use \VuFind\Cache\CacheTrait; + use \VuFind\Log\LoggerAwareTrait; use \VuFindHttp\HttpServiceAwareTrait; /** @@ -77,9 +80,9 @@ public function __invoke($url) { $useWebService = $this->config->EZproxy->prefixLinksWebServiceUrl ?? false; if ($useWebService) { - $usePrefix = $this->checkUrl($url); + $usePrefix = $this->checkUrl($url) ?? $this->checkConfig(); } else { - $usePrefix = $this->config->EZproxy->prefixLinks ?? true; + $usePrefix = $this->checkConfig(); } return ($usePrefix && isset($this->config->EZproxy->host)) @@ -87,12 +90,22 @@ public function __invoke($url) : $url; } + /** + * Return the configured prefixLinks setting. + * + * @return bool The configured setting, or the default + */ + private function checkConfig() + { + return $this->config->EZproxy->prefixLinks ?? true; + } + /** * Check whether the given URL requires the proxy prefix. Cache the repsonse. * * @param string $url The raw URL to check * - * @return bool Whether the URL should be prefixed + * @return mixed Whether the URL should be prefixed, or null if it can't be determined */ protected function checkUrl($url) { @@ -111,15 +124,20 @@ protected function checkUrl($url) * * @param $domain The domain * - * @return bool Whether the URL should be prefixed + * @return mixed Whether the URL should be prefixed, or null if it can't be determined */ protected function queryWebService($domain) { $prefixLinksWebServiceUrl = $this->config->EZproxy->prefixLinksWebServiceUrl; $queryUrl = $prefixLinksWebServiceUrl . '?url=' . $domain; - $client = $this->httpService->createClient($queryUrl); - $response = $client->send(); - $responseData = $response->getContent(); + try { + $client = $this->httpService->createClient($queryUrl); + $response = $client->send(); + $responseData = $response->getContent(); + } catch (Exception $ex) { + $this->logError('Exception during EZproxy web service request: ' . $ex->getMessage()); + return null; + } return ('1' === $responseData); } } From 7dbc72b6376b6731e0b40bad08aeb34e19f444f1 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 7 Nov 2023 17:54:21 +0000 Subject: [PATCH 03/16] Fix php-cs-fixer --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 4877bbc966d..d6ee161b7d1 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -32,6 +32,8 @@ use Exception; use Laminas\Cache\Storage\Adapter\AbstractAdapter as CacheAdapter; +use function intval; + /** * Proxy URL view helper * @@ -138,6 +140,6 @@ protected function queryWebService($domain) $this->logError('Exception during EZproxy web service request: ' . $ex->getMessage()); return null; } - return ('1' === $responseData); + return '1' === $responseData; } } From 375a2e6dba487f4762dec528a3631092f10b8f61 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 7 Nov 2023 18:00:34 +0000 Subject: [PATCH 04/16] Pass scheme and comain to web service --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index d6ee161b7d1..676ed7b13d5 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -111,12 +111,13 @@ private function checkConfig() */ protected function checkUrl($url) { - $domain = parse_url($url, PHP_URL_HOST); - $cacheKey = parse_url($url, PHP_URL_SCHEME) . '://' . $domain; - $usePrefix = $this->getCachedData("proxyUrl-domainToUsePrefix-$cacheKey"); + $domain = parse_url($url, PHP_URL_SCHEME) + . '://' + . parse_url($url, PHP_URL_HOST); + $usePrefix = $this->getCachedData("proxyUrl-domainToUsePrefix-$domain"); if (null === $usePrefix) { $usePrefix = $this->queryWebService($domain); - $this->putCachedData("proxyUrl-domainToUsePrefix-$cacheKey", $usePrefix); + $this->putCachedData("proxyUrl-domainToUsePrefix-$domain", $usePrefix); } return $usePrefix; } From e579bbb6bd48766342c8ff5f17f086b1d37d77e5 Mon Sep 17 00:00:00 2001 From: Maccabee Levine <31278545+maccabeelevine@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:04:37 -0500 Subject: [PATCH 05/16] Change default port Co-authored-by: Joe Corall --- config/vufind/config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 425f3ab6400..19820904b28 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -1456,7 +1456,7 @@ replace_other_urls = true ; query time is minimal. ; See https://github.com/lehigh-university-libraries/ezproxy-url-checker for an OSS ; implementation of this protocol that extrats the answers from EZproxy config. -;prefixLinksWebServiceUrl = http://localhost:8080/proxyUrl +;prefixLinksWebServiceUrl = http://localhost:8888/proxyUrl ; Duration (seconds) to cache web service response data. Default is 600. ;prefixLinksWebServiceCacheLifetime = 600 From f874a5b430fe5e60c20b2dcdc383bbdac71c0897 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Wed, 8 Nov 2023 20:14:36 +0000 Subject: [PATCH 06/16] Fix typos --- config/vufind/config.ini | 2 +- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 19820904b28..d19406e821f 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -1455,7 +1455,7 @@ replace_other_urls = true ; '1' to prefix and '0' if not. The web service should be hosted closely such that ; query time is minimal. ; See https://github.com/lehigh-university-libraries/ezproxy-url-checker for an OSS -; implementation of this protocol that extrats the answers from EZproxy config. +; implementation of this protocol that extracts the answers from EZproxy config. ;prefixLinksWebServiceUrl = http://localhost:8888/proxyUrl ; Duration (seconds) to cache web service response data. Default is 600. diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 676ed7b13d5..e63de110d51 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -61,7 +61,7 @@ class ProxyUrl extends \Laminas\View\Helper\AbstractHelper implements /** * Constructor * - * @param CacheAdapter $cache Cache for web service repsonses + * @param CacheAdapter $cache Cache for web service responses * @param \Laminas\Config\Config $config VuFind configuration */ public function __construct(CacheAdapter $cache = null, $config = null) @@ -103,7 +103,7 @@ private function checkConfig() } /** - * Check whether the given URL requires the proxy prefix. Cache the repsonse. + * Check whether the given URL requires the proxy prefix. Cache the response. * * @param string $url The raw URL to check * From 07a1be8b4fd89b4f2b57581e2ac8ee95eac0e15f Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Wed, 8 Nov 2023 20:28:14 +0000 Subject: [PATCH 07/16] Extract $cacheKey variable --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index e63de110d51..7c76907b996 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -114,10 +114,11 @@ protected function checkUrl($url) $domain = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST); - $usePrefix = $this->getCachedData("proxyUrl-domainToUsePrefix-$domain"); + $cacheKey = "proxyUrl-domainToUsePrefix-$domain"; + $usePrefix = $this->getCachedData($cacheKey); if (null === $usePrefix) { $usePrefix = $this->queryWebService($domain); - $this->putCachedData("proxyUrl-domainToUsePrefix-$domain", $usePrefix); + $this->putCachedData($cacheKey, $usePrefix); } return $usePrefix; } From 844902b1d3db84ce25f1494f3a810ce973ee60c1 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Wed, 8 Nov 2023 20:30:27 +0000 Subject: [PATCH 08/16] Fix function visibility --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 7c76907b996..987cd6d6cd5 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -97,7 +97,7 @@ public function __invoke($url) * * @return bool The configured setting, or the default */ - private function checkConfig() + protected function checkConfig() { return $this->config->EZproxy->prefixLinks ?? true; } From 8f55da1eed8043722595aa31e1367fb39d75083d Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Wed, 8 Nov 2023 20:46:11 +0000 Subject: [PATCH 09/16] Fix spacing --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 987cd6d6cd5..38722899636 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -135,7 +135,7 @@ protected function queryWebService($domain) $prefixLinksWebServiceUrl = $this->config->EZproxy->prefixLinksWebServiceUrl; $queryUrl = $prefixLinksWebServiceUrl . '?url=' . $domain; try { - $client = $this->httpService->createClient($queryUrl); + $client = $this->httpService->createClient($queryUrl); $response = $client->send(); $responseData = $response->getContent(); } catch (Exception $ex) { From 09cca15da1944a7ddf3a004ba55c492dad78343f Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Thu, 9 Nov 2023 22:49:25 +0000 Subject: [PATCH 10/16] URL-encode the domain parameter --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 38722899636..09878cb26d7 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -133,7 +133,7 @@ protected function checkUrl($url) protected function queryWebService($domain) { $prefixLinksWebServiceUrl = $this->config->EZproxy->prefixLinksWebServiceUrl; - $queryUrl = $prefixLinksWebServiceUrl . '?url=' . $domain; + $queryUrl = $prefixLinksWebServiceUrl . '?url=' . urlencode($domain); try { $client = $this->httpService->createClient($queryUrl); $response = $client->send(); From 899dde25921614358e9704a77d48ae53963f9bed Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Fri, 10 Nov 2023 17:49:33 +0000 Subject: [PATCH 11/16] Use $httpService->get --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 09878cb26d7..914e93c9465 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -133,10 +133,8 @@ protected function checkUrl($url) protected function queryWebService($domain) { $prefixLinksWebServiceUrl = $this->config->EZproxy->prefixLinksWebServiceUrl; - $queryUrl = $prefixLinksWebServiceUrl . '?url=' . urlencode($domain); try { - $client = $this->httpService->createClient($queryUrl); - $response = $client->send(); + $response = $this->httpService->get($prefixLinksWebServiceUrl, ['url' => $domain]); $responseData = $response->getContent(); } catch (Exception $ex) { $this->logError('Exception during EZproxy web service request: ' . $ex->getMessage()); From 9b077a2b94daf9e12725ecedd91c2c134e99f24f Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Fri, 10 Nov 2023 17:51:58 +0000 Subject: [PATCH 12/16] Fix $cache to required param --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 914e93c9465..0de2f16d130 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -64,7 +64,7 @@ class ProxyUrl extends \Laminas\View\Helper\AbstractHelper implements * @param CacheAdapter $cache Cache for web service responses * @param \Laminas\Config\Config $config VuFind configuration */ - public function __construct(CacheAdapter $cache = null, $config = null) + public function __construct(CacheAdapter $cache, $config = null) { $this->config = $config; $this->setCacheStorage($cache); From 62f58cb0ebfc379f4cd5d07920adae13c0d85ed8 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Fri, 10 Nov 2023 17:59:20 +0000 Subject: [PATCH 13/16] Switch $cache to second argument --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 4 ++-- .../VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 0de2f16d130..614e7ffa1b5 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -61,10 +61,10 @@ class ProxyUrl extends \Laminas\View\Helper\AbstractHelper implements /** * Constructor * - * @param CacheAdapter $cache Cache for web service responses * @param \Laminas\Config\Config $config VuFind configuration + * @param CacheAdapter $cache Cache for web service responses */ - public function __construct(CacheAdapter $cache, $config = null) + public function __construct($config = null, CacheAdapter $cache = null) { $this->config = $config; $this->setCacheStorage($cache); diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php index d8e53f0936b..8e98188c032 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php @@ -68,10 +68,10 @@ public function __invoke( if (!empty($options)) { throw new \Exception('Unexpected options sent to factory.'); } - $cache = $container->get(\VuFind\Cache\Manager::class) - ->getCache('object'); $config = $container->get(\VuFind\Config\PluginManager::class) ->get('config'); - return new $requestedName($cache, $config); + $cache = $container->get(\VuFind\Cache\Manager::class) + ->getCache('object'); + return new $requestedName($config, $cache); } } From df62c68cb30b9f7215a220156598571e30e361ae Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Fri, 10 Nov 2023 18:04:16 +0000 Subject: [PATCH 14/16] Fix code styling --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php index 8e98188c032..fb375a4cc77 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrlFactory.php @@ -70,7 +70,7 @@ public function __invoke( } $config = $container->get(\VuFind\Config\PluginManager::class) ->get('config'); - $cache = $container->get(\VuFind\Cache\Manager::class) + $cache = $container->get(\VuFind\Cache\Manager::class) ->getCache('object'); return new $requestedName($config, $cache); } From e8273df66a7327b96d4ce883481983974769fb54 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Mon, 13 Nov 2023 13:01:15 +0000 Subject: [PATCH 15/16] Clarify fallback behavior --- config/vufind/config.ini | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index d19406e821f..f0a36d97f71 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -1450,11 +1450,11 @@ replace_other_urls = true ;prefixLinks = true ; Use a web service to determine whether to prefix each link, ignoring prefixLinks -; above. Query the configured URL via HTTP GET and a single query parameter, 'url', -; set to the link domain. The web service should return a body with a single number, -; '1' to prefix and '0' if not. The web service should be hosted closely such that -; query time is minimal. -; See https://github.com/lehigh-university-libraries/ezproxy-url-checker for an OSS +; above unless the web service call fails. Query the configured URL via HTTP GET +; and a single query parameter, 'url', set to the link domain. The web service +; should return a body with a single number, '1' to prefix and '0' if not. The +; web service should be hosted closely such that query time is minimal. See +; https://github.com/lehigh-university-libraries/ezproxy-url-checker for an OSS ; implementation of this protocol that extracts the answers from EZproxy config. ;prefixLinksWebServiceUrl = http://localhost:8888/proxyUrl From 6d4207b6e542055b1ea116876ee4e41666781b75 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Mon, 13 Nov 2023 13:06:31 +0000 Subject: [PATCH 16/16] Trim web service response --- module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php index 614e7ffa1b5..a3628e25802 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ProxyUrl.php @@ -135,7 +135,7 @@ protected function queryWebService($domain) $prefixLinksWebServiceUrl = $this->config->EZproxy->prefixLinksWebServiceUrl; try { $response = $this->httpService->get($prefixLinksWebServiceUrl, ['url' => $domain]); - $responseData = $response->getContent(); + $responseData = trim($response->getContent()); } catch (Exception $ex) { $this->logError('Exception during EZproxy web service request: ' . $ex->getMessage()); return null;