Skip to content

Commit

Permalink
Second round of changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-ds committed Feb 6, 2024
1 parent 08245d6 commit 4d2a932
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Proxy/HTTP/FilterAuthenticated.bambda
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -16,15 +20,14 @@ 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
&& !sessionCookieName.isEmpty()
&& 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
Expand All @@ -45,4 +48,4 @@ var filterDenyList = mimeType != MimeType.CSS
&& !path.endsWith(".png")
&& !path.endsWith(".css");

return (authHeader || sessionCookie) && (configNoFilter || filterDenyList) && (configNotInScopeOnly || inScope);
return (authHeader || sessionCookie) && (configNoFilter || filterDenyList) && (configNotInScopeOnly || request.isInScope());

0 comments on commit 4d2a932

Please sign in to comment.