Skip to content

Commit aabe46a

Browse files
committed
BUG: fix removed ACL condition in CORS configuration
1 parent aff0520 commit aabe46a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

controller/annotations/ingress/resSetCORS.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e
7878
HdrFormat: origin,
7979
Response: true,
8080
CondTest: a.parent.acl,
81+
Cond: "if",
8182
})
8283
case "cors-allow-methods":
8384
if a.parent.acl == "" {
@@ -99,6 +100,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e
99100
HdrFormat: input,
100101
Response: true,
101102
CondTest: a.parent.acl,
103+
Cond: "if",
102104
})
103105
case "cors-allow-headers":
104106
if a.parent.acl == "" {
@@ -110,6 +112,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e
110112
HdrFormat: "\"" + input + "\"",
111113
Response: true,
112114
CondTest: a.parent.acl,
115+
Cond: "if",
113116
})
114117
case "cors-max-age":
115118
if a.parent.acl == "" {
@@ -129,6 +132,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e
129132
HdrFormat: fmt.Sprintf("\"%d\"", maxage),
130133
Response: true,
131134
CondTest: a.parent.acl,
135+
Cond: "if",
132136
})
133137
case "cors-allow-credentials":
134138
if a.parent.acl == "" {
@@ -139,6 +143,7 @@ func (a ResSetCORSAnn) Process(k store.K8s, annotations ...map[string]string) (e
139143
HdrFormat: "\"true\"",
140144
Response: true,
141145
CondTest: a.parent.acl,
146+
Cond: "if",
142147
})
143148
default:
144149
err = fmt.Errorf("unknown cors annotation '%s'", a.name)

controller/haproxy/rules/setHdr.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type SetHdr struct {
1616
HdrFormat string
1717
Type Type
1818
CondTest string
19+
Cond string
1920
}
2021

2122
func (r SetHdr) GetType() Type {
@@ -50,6 +51,7 @@ func (r SetHdr) Create(client api.HAProxyClient, frontend *models.Frontend, ingr
5051
HdrName: r.HdrName,
5152
HdrFormat: r.HdrFormat,
5253
CondTest: r.CondTest,
54+
Cond: r.Cond,
5355
}
5456
return client.FrontendHTTPResponseRuleCreate(frontend.Name, httpRule, ingressACL)
5557
}

0 commit comments

Comments
 (0)