Minor oauth fix. A trailing slash will not be required on proxy basepaths to have key verification work properly.
diff --git a/oauth/index.js b/oauth/index.js index 0449e4a..63522ce 100644 --- a/oauth/index.js +++ b/oauth/index.js
@@ -203,6 +203,8 @@ // then check if that proxy is one of the authorized proxies in bootstrap const checkIfAuthorized = module.exports.checkIfAuthorized = function checkIfAuthorized(config, urlPath, proxy, decodedToken) { + var parsedUrl = url.parse(urlPath); + urlPath = parsedUrl.pathname; if (!decodedToken.api_product_list) { debug('no api product list'); return false; } return decodedToken.api_product_list.some(function (product) { @@ -219,6 +221,7 @@ debug('found matching proxy rule'); return; } + const apiproxy = tempApiProxy.includes(proxy.base_path) ? tempApiProxy : proxy.base_path + (tempApiProxy.startsWith("/") ? "" : "/") + tempApiProxy @@ -228,7 +231,7 @@ if(apiproxy.includes(SUPPORTED_DOUBLE_ASTERIK_PATTERN)){ const regex = apiproxy.replace(/\*\*/gi,".*") - matchesProxyRules = urlPath.match(regex) + matchesProxyRules = urlPath.match(regex) }else{ if(apiproxy.includes(SUPPORTED_SINGLE_ASTERIK_PATTERN)){ const regex = apiproxy.replace(/\*/gi,"[^/]+"); @@ -237,6 +240,7 @@ // if(apiproxy.includes(SUPPORTED_SINGLE_FORWARD_SLASH_PATTERN)){ // } matchesProxyRules = urlPath == apiproxy; + } } })