mirror of
https://github.com/traefik/traefik.git
synced 2026-04-19 20:51:13 +02:00
Fix auth-response-headers whitespace trimming in ingress-nginx provider
This commit is contained in:
parent
4fa1f31f79
commit
930ff2aa09
@ -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…
x
Reference in New Issue
Block a user