@marcel91200 / caddy Mirror · read-only / commits / 2153a81e
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 09:15 UTC

forwardauth: Canonicalize header fields (fix #5038) (#5097)

Matt Holt committed Oct 4, 2022 at 23:37 UTC 2153a81ec85da99dcd33aa87ff0df5d286f00e9d
1 file changed +18 -21
modules/caddyhttp/reverseproxy/forwardauth/caddyfile.go
+18 -21
@@ -38,29 +38,28 @@ func init() {
38 // configured for most™️ auth gateways that support forward auth. The typical
39 // config which looks something like this:
40 //
41 -// forward_auth auth-gateway:9091 {
42 -// uri /authenticate?redirect=https://auth.example.com
43 -// copy_headers Remote-User Remote-Email
44 -// }
41 +// forward_auth auth-gateway:9091 {
42 +// uri /authenticate?redirect=https://auth.example.com
43 +// copy_headers Remote-User Remote-Email
44 +// }
45 //
46 // is equivalent to a reverse_proxy directive like this:
47 //
48 -// reverse_proxy auth-gateway:9091 {
49 -// method GET
50 -// rewrite /authenticate?redirect=https://auth.example.com
48 +// reverse_proxy auth-gateway:9091 {
49 +// method GET
50 +// rewrite /authenticate?redirect=https://auth.example.com
51 //
52 -// header_up X-Forwarded-Method {method}
53 -// header_up X-Forwarded-Uri {uri}
54 -//
55 -// @good status 2xx
56 -// handle_response @good {
57 -// request_header {
58 -// Remote-User {http.reverse_proxy.header.Remote-User}
59 -// Remote-Email {http.reverse_proxy.header.Remote-Email}
60 -// }
61 -// }
62 -// }
52 +// header_up X-Forwarded-Method {method}
53 +// header_up X-Forwarded-Uri {uri}
54 //
55 +// @good status 2xx
56 +// handle_response @good {
57 +// request_header {
58 +// Remote-User {http.reverse_proxy.header.Remote-User}
59 +// Remote-Email {http.reverse_proxy.header.Remote-Email}
60 +// }
61 +// }
62 +// }
63 func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
64 if !h.Next() {
65 return nil, h.ArgErr()
@@ -196,9 +195,7 @@ func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error)
195 // need at least one handler in the routes for the response handling
196 // logic in reverse_proxy to not skip this entry as empty.
197 for from, to := range headersToCopy {
199 - handler.Request.Set[to] = []string{
200 - "{http.reverse_proxy.header." + from + "}",
201 - }
198 + handler.Request.Set.Set(to, "{http.reverse_proxy.header."+http.CanonicalHeaderKey(from)+"}")
199 }
200
201 goodResponseHandler.Routes = append(