Merge current v2.4 into v2.5
This commit is contained in:
commit
e78f172f02
6 changed files with 132 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
## [v2.4.13](https://github.com/traefik/traefik/tree/v2.4.13) (2021-07-30)
|
||||||
|
[All Commits](https://github.com/traefik/traefik/compare/v2.4.12...v2.4.13)
|
||||||
|
|
||||||
|
**Bug fixes:**
|
||||||
|
- **[authentication,middleware]** Remove hop-by-hop headers define in connection header beore some middleware ([#8319](https://github.com/traefik/traefik/pull/8319) by [ldez](https://github.com/ldez))
|
||||||
|
|
||||||
## [v2.4.12](https://github.com/traefik/traefik/tree/v2.4.12) (2021-07-26)
|
## [v2.4.12](https://github.com/traefik/traefik/tree/v2.4.12) (2021-07-26)
|
||||||
[All Commits](https://github.com/traefik/traefik/compare/v2.4.11...v2.4.12)
|
[All Commits](https://github.com/traefik/traefik/compare/v2.4.11...v2.4.12)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
||||||
"github.com/traefik/traefik/v2/pkg/log"
|
"github.com/traefik/traefik/v2/pkg/log"
|
||||||
"github.com/traefik/traefik/v2/pkg/middlewares"
|
"github.com/traefik/traefik/v2/pkg/middlewares"
|
||||||
|
"github.com/traefik/traefik/v2/pkg/middlewares/connectionheader"
|
||||||
"github.com/traefik/traefik/v2/pkg/tracing"
|
"github.com/traefik/traefik/v2/pkg/tracing"
|
||||||
"github.com/vulcand/oxy/forward"
|
"github.com/vulcand/oxy/forward"
|
||||||
"github.com/vulcand/oxy/utils"
|
"github.com/vulcand/oxy/utils"
|
||||||
|
@ -89,7 +90,7 @@ func NewForward(ctx context.Context, next http.Handler, config dynamic.ForwardAu
|
||||||
fa.authResponseHeadersRegex = re
|
fa.authResponseHeadersRegex = re
|
||||||
}
|
}
|
||||||
|
|
||||||
return fa, nil
|
return connectionheader.Remover(fa), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fa *forwardAuth) GetTracingInformation() (string, ext.SpanKindEnum) {
|
func (fa *forwardAuth) GetTracingInformation() (string, ext.SpanKindEnum) {
|
||||||
|
|
46
pkg/middlewares/connectionheader/connectionheader.go
Normal file
46
pkg/middlewares/connectionheader/connectionheader.go
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package connectionheader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/textproto"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/net/http/httpguts"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
connectionHeader = "Connection"
|
||||||
|
upgradeHeader = "Upgrade"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Remover removes hop-by-hop headers listed in the "Connection" header.
|
||||||
|
// See RFC 7230, section 6.1.
|
||||||
|
func Remover(next http.Handler) http.HandlerFunc {
|
||||||
|
return func(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
var reqUpType string
|
||||||
|
if httpguts.HeaderValuesContainsToken(req.Header[connectionHeader], upgradeHeader) {
|
||||||
|
reqUpType = req.Header.Get(upgradeHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
removeConnectionHeaders(req.Header)
|
||||||
|
|
||||||
|
if reqUpType != "" {
|
||||||
|
req.Header.Set(connectionHeader, upgradeHeader)
|
||||||
|
req.Header.Set(upgradeHeader, reqUpType)
|
||||||
|
} else {
|
||||||
|
req.Header.Del(connectionHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
next.ServeHTTP(rw, req)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeConnectionHeaders(h http.Header) {
|
||||||
|
for _, f := range h[connectionHeader] {
|
||||||
|
for _, sf := range strings.Split(f, ",") {
|
||||||
|
if sf = textproto.TrimString(sf); sf != "" {
|
||||||
|
h.Del(sf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
71
pkg/middlewares/connectionheader/connectionheader_test.go
Normal file
71
pkg/middlewares/connectionheader/connectionheader_test.go
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
package connectionheader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRemover(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
desc string
|
||||||
|
reqHeaders map[string]string
|
||||||
|
expected http.Header
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
desc: "simple remove",
|
||||||
|
reqHeaders: map[string]string{
|
||||||
|
"Foo": "bar",
|
||||||
|
connectionHeader: "foo",
|
||||||
|
},
|
||||||
|
expected: http.Header{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "remove and Upgrade",
|
||||||
|
reqHeaders: map[string]string{
|
||||||
|
upgradeHeader: "test",
|
||||||
|
"Foo": "bar",
|
||||||
|
connectionHeader: "Upgrade,foo",
|
||||||
|
},
|
||||||
|
expected: http.Header{
|
||||||
|
upgradeHeader: []string{"test"},
|
||||||
|
connectionHeader: []string{"Upgrade"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "no remove",
|
||||||
|
reqHeaders: map[string]string{
|
||||||
|
"Foo": "bar",
|
||||||
|
connectionHeader: "fii",
|
||||||
|
},
|
||||||
|
expected: http.Header{
|
||||||
|
"Foo": []string{"bar"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range testCases {
|
||||||
|
test := test
|
||||||
|
t.Run(test.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
next := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {})
|
||||||
|
|
||||||
|
h := Remover(next)
|
||||||
|
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "https://localhost", nil)
|
||||||
|
|
||||||
|
for k, v := range test.reqHeaders {
|
||||||
|
req.Header.Set(k, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
rw := httptest.NewRecorder()
|
||||||
|
|
||||||
|
h.ServeHTTP(rw, req)
|
||||||
|
|
||||||
|
assert.Equal(t, test.expected, req.Header)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
||||||
"github.com/traefik/traefik/v2/pkg/log"
|
"github.com/traefik/traefik/v2/pkg/log"
|
||||||
"github.com/traefik/traefik/v2/pkg/middlewares"
|
"github.com/traefik/traefik/v2/pkg/middlewares"
|
||||||
|
"github.com/traefik/traefik/v2/pkg/middlewares/connectionheader"
|
||||||
"github.com/traefik/traefik/v2/pkg/tracing"
|
"github.com/traefik/traefik/v2/pkg/tracing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -68,11 +69,12 @@ func New(ctx context.Context, next http.Handler, cfg dynamic.Headers, name strin
|
||||||
|
|
||||||
if hasCustomHeaders || hasCorsHeaders {
|
if hasCustomHeaders || hasCorsHeaders {
|
||||||
logger.Debugf("Setting up customHeaders/Cors from %v", cfg)
|
logger.Debugf("Setting up customHeaders/Cors from %v", cfg)
|
||||||
var err error
|
h, err := NewHeader(nextHandler, cfg)
|
||||||
handler, err = NewHeader(nextHandler, cfg)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handler = connectionheader.Remover(h)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &headers{
|
return &headers{
|
||||||
|
|
|
@ -4,11 +4,11 @@ RepositoryName = "traefik"
|
||||||
OutputType = "file"
|
OutputType = "file"
|
||||||
FileName = "traefik_changelog.md"
|
FileName = "traefik_changelog.md"
|
||||||
|
|
||||||
# example new bugfix v2.4.12
|
# example new bugfix v2.4.13
|
||||||
CurrentRef = "v2.4"
|
CurrentRef = "v2.4"
|
||||||
PreviousRef = "v2.4.11"
|
PreviousRef = "v2.4.12"
|
||||||
BaseBranch = "v2.4"
|
BaseBranch = "v2.4"
|
||||||
FutureCurrentRefName = "v2.4.12"
|
FutureCurrentRefName = "v2.4.13"
|
||||||
|
|
||||||
ThresholdPreviousRef = 10
|
ThresholdPreviousRef = 10
|
||||||
ThresholdCurrentRef = 10
|
ThresholdCurrentRef = 10
|
||||||
|
|
Loading…
Reference in a new issue