From 4d2a932f0c7e946bf0e80f9540924113e5090472 Mon Sep 17 00:00:00 2001 From: joe-ds Date: Tue, 6 Feb 2024 13:00:32 +0000 Subject: [PATCH] Second round of changes. --- Proxy/HTTP/FilterAuthenticated.bambda | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Proxy/HTTP/FilterAuthenticated.bambda b/Proxy/HTTP/FilterAuthenticated.bambda index c91efa3..13302f9 100644 --- a/Proxy/HTTP/FilterAuthenticated.bambda +++ b/Proxy/HTTP/FilterAuthenticated.bambda @@ -4,10 +4,14 @@ * @author joe-ds (https://github.com/joe-ds) **/ +if (!requestResponse.hasResponse()) { + return false; +} + var request = requestResponse.request(); var response = requestResponse.response(); -if (!response.isStatusCodeClass(StatusCodeClass.CLASS_2XX_SUCCESS) || !requestResponse.hasResponse()) { +if (!response.isStatusCodeClass(StatusCodeClass.CLASS_2XX_SUCCESS)) { return false; } @@ -16,7 +20,6 @@ var configNotInScopeOnly = true; // If set to false, won't show out-of-scope it var sessionCookieName = ""; // If given, will look for a cookie with that name. var sessionCookieValue = ""; // If given, will check if cookie with sessionCookieName has this value. -var inScope = request.isInScope(); var authHeader = request.hasHeader("Authorization"); boolean sessionCookie = request.headerValue("Cookie") != null @@ -24,7 +27,7 @@ boolean sessionCookie = request.headerValue("Cookie") != null && request.hasParameter(sessionCookieName, HttpParameterType.COOKIE) && (sessionCookieValue.isEmpty() || sessionCookieValue.equals(request.parameter(sessionCookieName, HttpParameterType.COOKIE).value())); -var path = requestResponse.request().pathWithoutQuery().toLowerCase(); +var path = request.pathWithoutQuery().toLowerCase(); var mimeType = requestResponse.mimeType(); var filterDenyList = mimeType != MimeType.CSS && mimeType != MimeType.IMAGE_UNKNOWN @@ -45,4 +48,4 @@ var filterDenyList = mimeType != MimeType.CSS && !path.endsWith(".png") && !path.endsWith(".css"); -return (authHeader || sessionCookie) && (configNoFilter || filterDenyList) && (configNotInScopeOnly || inScope); \ No newline at end of file +return (authHeader || sessionCookie) && (configNoFilter || filterDenyList) && (configNotInScopeOnly || request.isInScope()); \ No newline at end of file