Skip to content

Commit

Permalink
CacheFilter bypasses cache for requests with authorization headers - e…
Browse files Browse the repository at this point in the history
…nvoyproxy#7198

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
  • Loading branch information
yosrym93 committed Jun 15, 2020
1 parent 83b8b5f commit dcb3858
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/extensions/filters/http/cache/cache_filter_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bool CacheFilterUtils::isCacheableRequest(const Http::RequestHeaderMap& headers)
const Http::HeaderValues& header_values = Http::Headers::get();
// TODO(toddmgreer): Also serve HEAD requests from cache.
// TODO(toddmgreer): Check all the other cache-related headers.
return method && forwarded_proto && headers.Path() && headers.Host() &&
return method && forwarded_proto && !headers.Authorization() && headers.Path() && headers.Host() &&
(method->value() == header_values.MethodValues.Get) &&
(forwarded_proto->value() == header_values.SchemeValues.Http ||
forwarded_proto->value() == header_values.SchemeValues.Https);
Expand Down
14 changes: 9 additions & 5 deletions test/extensions/filters/http/cache/cache_filter_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,27 @@ IsCacheableRequestParams params[] = {
false
},
{
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "https"}, {":authority", "test"}},
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "https"}, {":authority", "test.com"}},
true
},
{
{{":path", "/"}, {":method", "POST"}, {"x-forwarded-proto", "https"}, {":authority", "test"}},
{{":path", "/"}, {":method", "POST"}, {"x-forwarded-proto", "https"}, {":authority", "test.com"}},
false
},
{
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test"}},
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test.com"}},
true
},
{
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test"}},
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test.com"}},
true
},
{
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "ftp"}, {":authority", "test"}},
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "ftp"}, {":authority", "test.com"}},
false
},
{
{{":path", "/"}, {":method", "GET"}, {"x-forwarded-proto", "http"}, {":authority", "test.com"}, {"authorization", "basic YWxhZGRpbjpvcGVuc2VzYW1l"}},
false
},
};
Expand Down

0 comments on commit dcb3858

Please sign in to comment.