Skip to content

Commit

Permalink
allow same origin iframing in kurl proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig O'Donnell committed Jun 13, 2024
1 parent 91e6a9c commit 95ac369
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions kurl_proxy/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ func getHttpsServer(upstream, dexUpstream *url.URL, tlsSecretName string, secret

// CSPMiddleware adds Content-Security-Policy and X-Frame-Options headers to the response.
func CSPMiddleware(c *gin.Context) {
c.Writer.Header().Set("Content-Security-Policy", "frame-ancestors 'none';")
c.Writer.Header().Set("X-Frame-Options", "DENY")
c.Writer.Header().Set("Content-Security-Policy", "frame-ancestors 'self';")
c.Writer.Header().Set("X-Frame-Options", "SAMEORIGIN")
c.Next()
}

Expand Down
22 changes: 11 additions & 11 deletions kurl_proxy/cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ func Test_httpServerCSPHeaders(t *testing.T) {
httpServer: getHttpServer("some-fingerprint", true, tmpDir),
path: "/assets/index.html",
wantHeaders: map[string]string{
"Content-Security-Policy": "frame-ancestors 'none';",
"X-Frame-Options": "DENY",
"Content-Security-Policy": "frame-ancestors 'self';",
"X-Frame-Options": "SAMEORIGIN",
},
},
{
Expand All @@ -191,8 +191,8 @@ func Test_httpServerCSPHeaders(t *testing.T) {
isHttps: true,
path: "/tls/assets/index.html",
wantHeaders: map[string]string{
"Content-Security-Policy": "frame-ancestors 'none';",
"X-Frame-Options": "DENY",
"Content-Security-Policy": "frame-ancestors 'self';",
"X-Frame-Options": "SAMEORIGIN",
},
},
}
Expand Down Expand Up @@ -275,15 +275,15 @@ func Test_generateDefaultCertSecret(t *testing.T) {

func Test_generateCertHostnames(t *testing.T) {
tests := []struct {
name string
name string
namespace string
hostname string
altNames []string
altNames []string
}{
{
name: "with no namespace",
hostname: "kotsadm.default.svc.cluster.local",
altNames : []string{
name: "with no namespace",
hostname: "kotsadm.default.svc.cluster.local",
altNames: []string{
"kotsadm",
"kotsadm.default",
"kotsadm.default.svc",
Expand All @@ -292,10 +292,10 @@ func Test_generateCertHostnames(t *testing.T) {
},
},
{
name: "with some other namespace",
name: "with some other namespace",
namespace: "somecluster",
hostname: "kotsadm.default.svc.cluster.local",
altNames : []string{
altNames: []string{
"kotsadm",
"kotsadm.default",
"kotsadm.default.svc",
Expand Down

0 comments on commit 95ac369

Please sign in to comment.