Skip to content

[VCL] Keep user context headers in debug mode #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions resources/config/varnish-3/fos_user_context.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@ sub fos_user_context_deliver {
return (restart);
}

# If we get here, this is a real response that gets sent to the client.

# Remove the vary on context user hash, this is nothing public. Keep all
# other vary headers.
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
set resp.http.Vary = regsub(resp.http.Vary, "^, *", "");
if (resp.http.Vary == "") {
remove resp.http.Vary;
}
# If we get here, this is a real response that gets sent to the client and we do some cleanup if not in debug.

if (!resp.http.X-Cache-Debug) {
# Remove the vary on context user hash, this is nothing public. Keep all
# other vary headers.
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
set resp.http.Vary = regsub(resp.http.Vary, "^, *", "");
if (resp.http.Vary == "") {
remove resp.http.Vary;
}

# Sanity check to prevent ever exposing the hash to a client.
remove resp.http.X-User-Context-Hash;
# Sanity check to prevent ever exposing the hash to a client.
remove resp.http.X-User-Context-Hash;
}
}
24 changes: 13 additions & 11 deletions resources/config/varnish/fos_user_context.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,18 @@ sub fos_user_context_deliver {
return (restart);
}

# If we get here, this is a real response that gets sent to the client.

# Remove the vary on context user hash, this is nothing public. Keep all
# other vary headers.
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
set resp.http.Vary = regsub(resp.http.Vary, "^, *", "");
if (resp.http.Vary == "") {
unset resp.http.Vary;
}
# If we get here, this is a real response that gets sent to the client and we do some cleanup if not in debug.

if (!resp.http.X-Cache-Debug) {
# Remove the vary on context user hash, this is nothing public. Keep all
# other vary headers.
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
set resp.http.Vary = regsub(resp.http.Vary, "^, *", "");
if (resp.http.Vary == "") {
unset resp.http.Vary;
}

# Sanity check to prevent ever exposing the hash to a client.
unset resp.http.X-User-Context-Hash;
# Sanity check to prevent ever exposing the hash to a client.
unset resp.http.X-User-Context-Hash;
}
}