Skip to content

Commit

Permalink
BUG: fix removed ACL condition in CORS configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmatmati authored and oktalz committed Apr 22, 2022
1 parent 9464b03 commit 3ad3409
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions controller/annotations/ingress/resSetCORS.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand All @@ -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 == "" {
Expand All @@ -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 == "" {
Expand All @@ -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 == "" {
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions controller/haproxy/rules/setHdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type SetHdr struct {
HdrFormat string
Type Type
CondTest string
Cond string
}

func (r SetHdr) GetType() Type {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 3ad3409

Please sign in to comment.