diff --git a/app/Http/Middleware/SecureHeaders.php b/app/Http/Middleware/SecureHeaders.php index 36b9c73bf3..bda07c06bd 100644 --- a/app/Http/Middleware/SecureHeaders.php +++ b/app/Http/Middleware/SecureHeaders.php @@ -34,20 +34,24 @@ use Illuminate\Support\Str; class SecureHeaders { /** - * Handle an incoming request. May not be a limited user (ie. Sandstorm env. or demo user). + * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Closure $next * * @return mixed + * @throws \Exception */ public function handle(Request $request, Closure $next) { + $nonce = base64_encode(random_bytes(16)); + app('view')->share('JS_NONCE', $nonce); + $response = $next($request); $google = ''; $googleImg = ''; $analyticsId = config('firefly.analytics_id'); - $token = Str::random(16); + if ('' !== $analyticsId) { $google = 'www.googletagmanager.com/gtag/js https://www.google-analytics.com/analytics.js'; // @codeCoverageIgnore $googleImg = 'https://www.google-analytics.com/'; @@ -55,7 +59,7 @@ class SecureHeaders $csp = [ "default-src 'none'", "object-src 'self'", - sprintf("script-src 'self' 'unsafe-inline' %s", $google), + sprintf("script-src 'nonce-%s' %s", $nonce, $google), "style-src 'self' 'unsafe-inline'", "base-uri 'self'", "font-src 'self' data:", diff --git a/resources/views/v1/accounts/create.twig b/resources/views/v1/accounts/create.twig index 08eddbf47f..8cd242fea7 100644 --- a/resources/views/v1/accounts/create.twig +++ b/resources/views/v1/accounts/create.twig @@ -4,7 +4,7 @@ {% endblock %} {% block content %} - diff --git a/resources/views/v1/accounts/edit.twig b/resources/views/v1/accounts/edit.twig index be9bb10ac2..b8740d710c 100644 --- a/resources/views/v1/accounts/edit.twig +++ b/resources/views/v1/accounts/edit.twig @@ -6,7 +6,7 @@ {% block content %} - diff --git a/resources/views/v1/accounts/index.twig b/resources/views/v1/accounts/index.twig index ec6088e853..c6c303eb28 100644 --- a/resources/views/v1/accounts/index.twig +++ b/resources/views/v1/accounts/index.twig @@ -75,7 +75,7 @@ {% endblock %} {% block scripts %} - diff --git a/resources/views/v1/accounts/reconcile/edit.twig b/resources/views/v1/accounts/reconcile/edit.twig index 6639ed11c6..65bd5578b5 100644 --- a/resources/views/v1/accounts/reconcile/edit.twig +++ b/resources/views/v1/accounts/reconcile/edit.twig @@ -93,7 +93,7 @@ {% endblock %} {% block scripts %} - diff --git a/resources/views/v1/accounts/reconcile/index.twig b/resources/views/v1/accounts/reconcile/index.twig index 7b733991cd..4ee9017e99 100644 --- a/resources/views/v1/accounts/reconcile/index.twig +++ b/resources/views/v1/accounts/reconcile/index.twig @@ -126,7 +126,7 @@ {% endblock %} {% block scripts %} - - + {% endblock %} diff --git a/resources/views/v1/accounts/show.twig b/resources/views/v1/accounts/show.twig index a21dda5903..4f17701d8e 100644 --- a/resources/views/v1/accounts/show.twig +++ b/resources/views/v1/accounts/show.twig @@ -156,7 +156,7 @@ {% endblock %} {% block scripts %} - - + {% endblock %} diff --git a/resources/views/v1/bills/index.twig b/resources/views/v1/bills/index.twig index e50fb8950a..286d18c865 100644 --- a/resources/views/v1/bills/index.twig +++ b/resources/views/v1/bills/index.twig @@ -42,7 +42,7 @@ {% endblock %} {% block scripts %} - diff --git a/resources/views/v1/bills/show.twig b/resources/views/v1/bills/show.twig index a78f45ec38..1aecda481c 100644 --- a/resources/views/v1/bills/show.twig +++ b/resources/views/v1/bills/show.twig @@ -177,7 +177,7 @@ {% endblock %} {% block scripts %} - diff --git a/resources/views/v1/index.twig b/resources/views/v1/index.twig index 673f4cd63d..f75d395092 100644 --- a/resources/views/v1/index.twig +++ b/resources/views/v1/index.twig @@ -154,7 +154,7 @@ {% endblock %} {% block scripts %} - - - - - - + + + + + {% endblock %} {% block styles %} {% endblock %} diff --git a/resources/views/v1/layout/default.twig b/resources/views/v1/layout/default.twig index f9c816d898..07466e510b 100644 --- a/resources/views/v1/layout/default.twig +++ b/resources/views/v1/layout/default.twig @@ -41,13 +41,13 @@ {# Any local custom CSS. #} {% block styles %}{% endblock %} {# this entry is in the header so it's loaded early #} {# SHA256: C45493A8175B10AC47EEDFC7C20AC31FAE5C804FB6C4F75468DB0F95112664BF #} - + {# favicons #} {% include('partials.favicons') %} @@ -176,31 +176,31 @@ {# Java libraries and stuff: #} {# Moment JS #} - - + + {# All kinds of variables. #} - + {# big fat JS thing courtesy of Vue#} - + {# date range picker, current template, etc.#} - - - + + + {# Firefly III code#} - - + + {% if not shownDemo %} - - - + + {% endif %} {% block scripts %}{% endblock %} @@ -208,8 +208,8 @@ - - +