Skip to content

Commit 64517d9

Browse files
author
INFORMATICA\rmekala
committed
Added a case for banning user context hash object. Partial fix for FriendsOfSymfony#482
1 parent fa2239e commit 64517d9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

resources/config/varnish/fos_ban.vcl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ sub fos_ban_recv {
2121
// the left side is the response header, the right side the invalidation header
2222
+ " && obj.http.X-Cache-Tags ~ " + req.http.X-Cache-Tags
2323
);
24+
} elseif(req.http.Cookie) {
25+
ban("obj.http.X-Host ~ " + req.http.X-Host
26+
+ " && obj.http.X-Url ~ " + req.http.X-Url
27+
+ " && obj.http.content-type ~ " + req.http.X-Content-Type
28+
+ " && obj.http.Cookie ~ " + req.http.Cookie
29+
);
2430
} else {
2531
ban("obj.http.X-Host ~ " + req.http.X-Host
2632
+ " && obj.http.X-Url ~ " + req.http.X-Url
@@ -37,6 +43,9 @@ sub fos_ban_backend_response {
3743
# Set ban-lurker friendly custom headers
3844
set beresp.http.X-Url = bereq.url;
3945
set beresp.http.X-Host = bereq.http.host;
46+
if (bereq.http.accept ~ "application/vnd.fos.user-context-hash") {
47+
set beresp.http.Cookie = ";" + bereq.http.Cookie;
48+
}
4049
}
4150

4251
sub fos_ban_deliver {
@@ -46,6 +55,7 @@ sub fos_ban_deliver {
4655
# Remove ban-lurker friendly custom headers when delivering to client
4756
unset resp.http.X-Url;
4857
unset resp.http.X-Host;
58+
unset resp.http.Cookie;
4959

5060
# Unset the tagged cache headers
5161
unset resp.http.X-Cache-Tags;

0 commit comments

Comments
 (0)