Skip to content

Commit 701444c

Browse files
committed
refactor(apps-proxy): inline kai-preview CSP helper into bootstrap handler
1 parent 7b7c265 commit 701444c

3 files changed

Lines changed: 6 additions & 43 deletions

File tree

internal/pkg/service/appsproxy/proxy/apphandler/authproxy/kaipreview/bootstrap.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"html/template"
77
"net/http"
8+
"strings"
89

910
"github.com/keboola/keboola-as-code/internal/pkg/utils/errors"
1011
)
@@ -43,7 +44,11 @@ func (h *BootstrapHandler) ServeHTTPOrError(w http.ResponseWriter, r *http.Reque
4344
return nil
4445
}
4546

46-
WriteFrameAncestorsCSP(w, h.allowedOrigins)
47+
if len(h.allowedOrigins) == 0 {
48+
w.Header().Set("Content-Security-Policy", "frame-ancestors 'none'")
49+
} else {
50+
w.Header().Set("Content-Security-Policy", "frame-ancestors "+strings.Join(h.allowedOrigins, " "))
51+
}
4752
w.Header().Set("Content-Type", "text/html; charset=utf-8")
4853
w.Header().Set("Cache-Control", "no-store")
4954

internal/pkg/service/appsproxy/proxy/apphandler/authproxy/kaipreview/csp.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

internal/pkg/service/appsproxy/proxy/apphandler/authproxy/kaipreview/csp_test.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)