Add security headers to the website.

The one bit of JS we have for the mobile menu needed some tweaking.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2021-02-23 14:26:58 -06:00
parent 60034b39a3
commit a4089fcc72
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D
3 changed files with 13 additions and 2 deletions

View File

@ -33,3 +33,11 @@ HUGO_ENABLEGITINFO = "true"
for = "/fonts/*" for = "/fonts/*"
[headers.values] [headers.values]
Access-Control-Allow-Origin = "*" Access-Control-Allow-Origin = "*"
[[headers]]
for = "/*"
[headers.values]
Content-Security-Policy = "default-src 'self'; img-src *"
X-Content-Type-Options = "nosniff"
X-Frame-Options = "DENY"
X-XSS-Protection = "1; mode=block"

View File

@ -7,7 +7,7 @@
<li><a href="/blog/" {{ if or (eq .Page.Section "posts") (eq .Page.Section "tags") }}class="active"{{ end }}>Blog</a></li> <li><a href="/blog/" {{ if or (eq .Page.Section "posts") (eq .Page.Section "tags") }}class="active"{{ end }}>Blog</a></li>
<li><a href="/docs/" {{ if (eq .Page.Section "docs") }}class="active"{{ end }}>Docs</a></li> <li><a href="/docs/" {{ if (eq .Page.Section "docs") }}class="active"{{ end }}>Docs</a></li>
</ul> </ul>
<button type="button" class="mobile" onclick="mobileNavToggle()"> <button type="button" class="mobile" id="mobile-menu-button">
<img class="collapsed-icon" src="/img/hamburger.svg" alt="Mobile nav icon"> <img class="collapsed-icon" src="/img/hamburger.svg" alt="Mobile nav icon">
<img class="expanded-icon" src="/img/close.svg" alt="Mobile nav icon"> <img class="expanded-icon" src="/img/close.svg" alt="Mobile nav icon">
</button> </button>

View File

@ -3,4 +3,7 @@
function mobileNavToggle() { function mobileNavToggle() {
var menu = document.getElementById("mobile-menu").parentElement; var menu = document.getElementById("mobile-menu").parentElement;
menu.classList.toggle('mobile-menu-visible'); menu.classList.toggle('mobile-menu-visible');
} }
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('mobile-menu-button').addEventListener('click', mobileNavToggle);
});