Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.5' into 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Nocoń committed May 5, 2020
2 parents a33446c + 7db150f commit 39f0b9b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PHP_IMAGE=ezsystems/php:7.3-v1
PHP_IMAGE_DEV=ezsystems/php:7.3-v1-dev
NGINX_IMAGE=nginx:stable
MYSQL_IMAGE=healthcheck/mariadb
SELENIUM_IMAGE=selenium/standalone-chrome-debug:3.141.59-oxygen
SELENIUM_IMAGE=selenium/standalone-chrome-debug:3.141.59-20200326
REDIS_IMAGE=healthcheck/redis

APP_DOCKER_FILE=doc/docker/Dockerfile-app
Expand Down
9 changes: 6 additions & 3 deletions .platform/varnish.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Make sure to at least adjust default parameters.yml, defaults there reflect our testing needs with docker.

// Not applicable on Platform.sh:
//vcl 4.1;
//vcl 4.0;
//import std;
import xkey;

Expand All @@ -26,6 +26,7 @@ acl debuggers {

// Called at the beginning of a request, after the complete request has been received
sub vcl_recv {

// Set the backend
//set req.backend_hint = ezplatform;
// Platform.sh specific:
Expand Down Expand Up @@ -116,6 +117,7 @@ sub vcl_hit {

// Called when the requested object has been retrieved from the backend
sub vcl_backend_response {

if (bereq.http.accept ~ "application/vnd.fos.user-context-hash"
&& beresp.status >= 500
) {
Expand Down Expand Up @@ -194,13 +196,14 @@ sub ez_purge_acl {

// Sub-routine to get client user context hash, used to for being able to vary page cache on user rights.
sub ez_user_context_hash {

// Prevent tampering attacks on the hash mechanism
if (req.restarts == 0
&& (req.http.accept ~ "application/vnd.fos.user-context-hash"
|| req.http.x-user-hash
)
) {
return (synth(400));
return (synth(400, "Bad Request"));
}

if (req.restarts == 0 && (req.method == "GET" || req.method == "HEAD")) {
Expand Down Expand Up @@ -248,7 +251,7 @@ sub ez_invalidate_token {
|| req.http.x-backend-invalidate-token
)
) {
return (synth(400));
return (synth(400, "Bad Request"));
}

if (req.restarts == 0 && req.method == "PURGE" && req.http.x-invalidate-token) {
Expand Down
1 change: 1 addition & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ default:
capabilities:
extra_capabilities:
chromeOptions:
w3c: false
args:
- "--window-size=1440,1080"
- "--no-sandbox"
Expand Down
29 changes: 20 additions & 9 deletions doc/varnish/vcl/varnish4_xkey.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ sub vcl_backend_response {

// Make Varnish keep all objects for up to 1 hour beyond their TTL, see vcl_hit for Request logic on this
set beresp.grace = 1h;

// Compressing the content
if (beresp.http.Content-Type ~ "application/javascript"
|| beresp.http.Content-Type ~ "application/json"
|| beresp.http.Content-Type ~ "application/vnd.ms-fontobject"
|| beresp.http.Content-Type ~ "application/vnd.ez.api"
|| beresp.http.Content-Type ~ "application/x-font-ttf"
|| beresp.http.Content-Type ~ "image/svg+xml"
|| beresp.http.Content-Type ~ "text/css"
|| beresp.http.Content-Type ~ "text/plain"
) {
set beresp.do_gzip = true;
}
}

// Handle purge
Expand Down Expand Up @@ -156,13 +169,11 @@ sub ez_purge {
}

sub ez_purge_acl {
// if (req.http.x-purge-token) {
// # Won't work on Varnish <= 5.1, if needed in 4.1 you can hardcode a secret token here instead of std.getenv() usage
// if (req.http.x-purge-token != std.getenv("HTTPCACHE_VARNISH_INVALIDATE_TOKEN")) {
// return (synth(405, "Method not allowed"));
// }
// } else if (!client.ip ~ invalidators) {
if (!client.ip ~ invalidators) {
if (req.http.x-invalidate-token) {
if (req.http.x-invalidate-token != req.http.x-backend-invalidate-token) {
return (synth(405, "Method not allowed"));
}
} else if (!client.ip ~ invalidators) {
return (synth(405, "Method not allowed"));
}
}
Expand All @@ -176,7 +187,7 @@ sub ez_user_context_hash {
|| req.http.x-user-hash
)
) {
return (synth(400));
return (synth(400, "Bad Request"));
}

if (req.restarts == 0 && (req.method == "GET" || req.method == "HEAD")) {
Expand Down Expand Up @@ -224,7 +235,7 @@ sub ez_invalidate_token {
|| req.http.x-backend-invalidate-token
)
) {
return (synth(400));
return (synth(400, "Bad Request"));
}

if (req.restarts == 0 && req.method == "PURGE" && req.http.x-invalidate-token) {
Expand Down

0 comments on commit 39f0b9b

Please sign in to comment.