From 3ad3409330d91b1581c0e766df29f6f5b5ffd5dd Mon Sep 17 00:00:00 2001 From: Ivan Matmati Date: Tue, 19 Apr 2022 11:25:12 +0200 Subject: [PATCH] BUG: fix removed ACL condition in CORS configuration --- controller/annotations/ingress/resSetCORS.go | 5 +++++ controller/haproxy/rules/setHdr.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/controller/annotations/ingress/resSetCORS.go b/controller/annotations/ingress/resSetCORS.go index 12d0d73b..012fe00e 100644 --- a/controller/annotations/ingress/resSetCORS.go +++ b/controller/annotations/ingress/resSetCORS.go @@ -78,6 +78,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e HdrFormat: origin, Response: true, CondTest: a.parent.acl, + Cond: "if", }) case "cors-allow-methods": if a.parent.acl == "" { @@ -99,6 +100,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e HdrFormat: input, Response: true, CondTest: a.parent.acl, + Cond: "if", }) case "cors-allow-headers": if a.parent.acl == "" { @@ -110,6 +112,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e HdrFormat: "\"" + input + "\"", Response: true, CondTest: a.parent.acl, + Cond: "if", }) case "cors-max-age": if a.parent.acl == "" { @@ -129,6 +132,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e HdrFormat: fmt.Sprintf("\"%d\"", maxage), Response: true, CondTest: a.parent.acl, + Cond: "if", }) case "cors-allow-credentials": if a.parent.acl == "" { @@ -139,6 +143,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e HdrFormat: "\"true\"", Response: true, CondTest: a.parent.acl, + Cond: "if", }) default: err = fmt.Errorf("unknown cors annotation '%s'", a.name) diff --git a/controller/haproxy/rules/setHdr.go b/controller/haproxy/rules/setHdr.go index aee886e9..b399d9ef 100644 --- a/controller/haproxy/rules/setHdr.go +++ b/controller/haproxy/rules/setHdr.go @@ -16,6 +16,7 @@ type SetHdr struct { HdrFormat string Type Type CondTest string + Cond string } func (r SetHdr) GetType() Type { @@ -50,6 +51,7 @@ func (r SetHdr) Create(client api.HAProxyClient, frontend *models.Frontend, ingr HdrName: r.HdrName, HdrFormat: r.HdrFormat, CondTest: r.CondTest, + Cond: r.Cond, } return client.FrontendHTTPResponseRuleCreate(frontend.Name, httpRule, ingressACL) }