Sign inSign up

floatp/traefik

By floatp

•Updated almost 6 years ago

A Traefik image with minor changes applied to the ForwardAuth middleware.

Image
0

322

floatp/traefik repository overview

⁠Traefik + three more lines

⁠Why

The Floatp Network Access Controller is acting as an external service for the Traefik ForwardAuth middleware. It (the external service) may set Set-Cookie headers in it's responses to the middleware, and it requires those headers to be copied into the response from the service (requested by the agent). This behaviour is not supported by Traefik. Fortunately, it is trivial to implement.

⁠How

$ git diff v2.3.2
diff --git a/pkg/middlewares/auth/forward.go b/pkg/middlewares/auth/forward.go
index e3a0bd06..ebf3dc62 100644
--- a/pkg/middlewares/auth/forward.go
+++ b/pkg/middlewares/auth/forward.go
@@ -154,6 +154,11 @@ func (fa *forwardAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
                }
        }
 
+       var setCookieHeaderKey = http.CanonicalHeaderKey("Set-Cookie")
+       for _, value := range forwardResponse.Header[setCookieHeaderKey] {
+               rw.Header().Add(setCookieHeaderKey, value)
+       }
+
        req.RequestURI = req.URL.RequestURI()
        fa.next.ServeHTTP(rw, req)
 }

Tag summary

Content type

Image

Digest

Size

23.8 MB

Last updated

almost 6 years ago

docker pull floatp/traefik