Skip to content

Commit 0e7b9d5

Browse files
author
Dawid Ciepiela
committed
take care of Permissions-Policy
1 parent b7ba5be commit 0e7b9d5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/api/endpoints/proxy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func (p ProxyState) ModifyResponse(resp *http.Response) error {
138138
resp.Header.Del("Access-Control-Allow-Headers")
139139
resp.Header.Del("Access-Control-Expose-Headers")
140140
resp.Header.Del("Access-Control-Max-Age")
141+
resp.Header.Del("Permissions-Policy")
141142

142143
// Ignore non-HTML content
143144
if contentType := resp.Header.Get("Content-Type"); resp.Body == nil || !strings.Contains(contentType, gin.MIMEHTML) {

pkg/common/web/utils.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ func SessionSave(session sessions.Session, ctx *gin.Context) (success bool) {
317317
// SetContentSecurityHeaders sets the Content-Security-Policy, X-Frame-Options, and X-Content-Type-Options headers.
318318
// It uses the nonce to set the script-src and style-src directives.
319319
func SetContentSecurityHeaders(w http.ResponseWriter, nonce string) {
320+
// Set Content-Security-Policy header
320321
w.Header().Set("Content-Security-Policy", strings.Join([]string{
321322
"default-src 'none'",
322323
"script-src 'self' 'nonce-" + nonce + "'",
@@ -332,6 +333,10 @@ func SetContentSecurityHeaders(w http.ResponseWriter, nonce string) {
332333
"worker-src 'none'",
333334
"upgrade-insecure-requests",
334335
}, "; "))
335-
w.Header().Set("X-Frame-Options", "DENY")
336+
337+
// Prevent MIME type sniffing
336338
w.Header().Set("X-Content-Type-Options", "nosniff")
339+
340+
// Prevent clickjacking
341+
w.Header().Set("X-Frame-Options", "DENY")
337342
}

0 commit comments

Comments
 (0)