mirror of
https://github.com/traefik/traefik.git
synced 2026-06-09 08:43:26 -04:00
Fix auth-response-headers whitespace trimming in ingress-nginx provider
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Build and Publish Documentation / Doc Process (push) Waiting to run
Build experimental image on branch / build-webui (push) Waiting to run
Build experimental image on branch / Build experimental image on branch (push) Waiting to run
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Build and Publish Documentation / Doc Process (push) Waiting to run
Build experimental image on branch / build-webui (push) Waiting to run
Build experimental image on branch / Build experimental image on branch (push) Waiting to run
This commit is contained in:
parent
4fa1f31f79
commit
930ff2aa09
3 changed files with 10 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ metadata:
|
|||
annotations:
|
||||
nginx.ingress.kubernetes.io/auth-url: "http://whoami.default.svc/"
|
||||
nginx.ingress.kubernetes.io/auth-method: "GET"
|
||||
nginx.ingress.kubernetes.io/auth-response-headers: "X-Foo"
|
||||
nginx.ingress.kubernetes.io/auth-response-headers: "X-Foo, X-Bar"
|
||||
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
|
|
|
|||
|
|
@ -1004,7 +1004,14 @@ func applyForwardAuthConfiguration(routerName string, ingressConfig ingressConfi
|
|||
return errors.New("empty auth-url found in ingress annotations")
|
||||
}
|
||||
|
||||
authResponseHeaders := strings.Split(ptr.Deref(ingressConfig.AuthResponseHeaders, ""), ",")
|
||||
var authResponseHeaders []string
|
||||
if raw := ptr.Deref(ingressConfig.AuthResponseHeaders, ""); raw != "" {
|
||||
for h := range strings.SplitSeq(raw, ",") {
|
||||
if trimmed := strings.TrimSpace(h); trimmed != "" {
|
||||
authResponseHeaders = append(authResponseHeaders, trimmed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forwardMiddlewareName := routerName + "-forward-auth"
|
||||
conf.HTTP.Middlewares[forwardMiddlewareName] = &dynamic.Middleware{
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ func TestLoadIngresses(t *testing.T) {
|
|||
"default-ingress-with-forwardauth-rule-0-path-0-forward-auth": {
|
||||
ForwardAuth: &dynamic.ForwardAuth{
|
||||
Address: "http://whoami.default.svc/",
|
||||
AuthResponseHeaders: []string{"X-Foo"},
|
||||
AuthResponseHeaders: []string{"X-Foo", "X-Bar"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue